interop

C# to VB6 COM events (“object or class does not support the set of events”)

旧街凉风 提交于 2019-11-30 21:10:20
Really pulling my hair out with this one... I have a C# project with an interface defined as: /* Externally Accessible API */ [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface ISerial { [DispId(1)] bool Startup(); [DispId(2)] bool Shutdown(); [DispId(3)] bool UserInput_FloorButton(int floor_number); [DispId(4)] bool Initialize(); } /* Externally Accesssible Event API */ [InterfaceType(ComInterfaceType.InterfaceIsIDispatch)] public interface ISerialEvent { [DispId(5)] void DataEvent(); } [ComSourceInterfaces(typeof(ISerialEvent), typeof(ISerial))] [ClassInterface

Using app.config with Interop Controls

廉价感情. 提交于 2019-11-30 20:56:26
I have a .net project (MySolution.Common) that uses the app.config. I am using the project MySolution.Common in an InteropUserControl project called MySolution.InteropCtrl. MySolution.InteropCtrl is embedded into a VB6 project. When the MySolution.InteropCtrl is in the VB6 project, It cannot find the app.config file. Everything in the InteropControl works in VB6 except for what depends on the information in the app.config file. What do I need to change so the MySolution.InteropCtrl can see the app.config file while in VB6? I'm not 100% sure on this. But I'll throw out some possibilities. First

Copy cells in excel using C#

≯℡__Kan透↙ 提交于 2019-11-30 20:19:31
How to copy to specific row in target sheet? I need to copy A1 to J10 from a sheet in one excel to location starting from A15 in second excel sheet. How can I achieve this in c#? In the below Copy method there seems to be no option to specify the location in target excel sheet. ObjWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)ObjWorkBookTemp.Sheets[1]; ObjWorkSheet.Copy(Type.Missing, ObjWorkBookGeneral.Sheets[1]); I think you are using the wrong method here... you want to use a Paste method not a copy method. Try the Range.PasteSpecial method... should do the trick for you. Something

Assembly generation failed — Referenced assembly 'Interop.Office' does not have a strong name

核能气质少年 提交于 2019-11-30 20:15:28
I have a WPF 4 project to interact with word documents made in VS2010 and a win form User Control project to host word application into it. And other com dlls. All com dlls are referred into my main wpf application. I want to publish my project so I can install it on another machine and perform automatic update for it, I get error: "Assembly generation failed -- Referenced assembly 'Interop.Office' does not have a strong name. ". error for each COM Dll. A dll refer to (Interop.word.dll, interop.office.dll, interop.VBIDE.dll) and all these dlls are also refer and used into my wpf code. I found

L prefix for strings in C++

那年仲夏 提交于 2019-11-30 20:04:57
I have a static library. This library have the following function defined int WriteData(LPTSTR s) The sample to call the function is LPTSTR s = (LPTSTR) L"Test Data"; int n = WriteData(s); WriteData return 0 on success and -1 on failure. I am writing a dynamic DLL to export this function. int TestFun(LPTSTR lpData) { return WriteData(lpData); } A C++ test application result LPTSTR s = (LPTSTR) L"Test Data"; TestFun(s); //OK return 0 LPTSTR s = (LPTSTR) "Test Data"; TestFun(s); //Fail return -1 I have to call it from a c# application. I assume my DLL-Import signature would be: [DllImport("Test

Communicating between C# and VBA

前提是你 提交于 2019-11-30 19:53:06
At the request of my boss I created a small set of scripts that are used to periodically monitor the status of certain devices and processes. This info is subsequently processed using a relatively elaborate VBA module that gathers all info, applies formulas, sets up ranges and generates graphs, etc. There are two problems however: I'm an amateur programmer, so my VBA routine is quite inefficient. That's not a huge problem for me (I just get up and get a coffee while it's running), but for other users this can be a hassle, as then don't know why it's taking so long. I want a graphical

Method not found: 'System.Type System.Runtime.InteropServices.Marshal.GetTypeFromCLSID(System.Guid)'

Deadly 提交于 2019-11-30 19:19:39
I spent a good deal of time writing this program on my dev box, after moving it to our production boxes I get the error below. Just an FYI I don't have any control over what is installed and what can be installed, how can I make this work? Under both framework on both computers we have v1.0.3705, v1.1.4322, v2.0.50727, v3.0, v3.5, 4.0.30319. Also the program I used to create the app is Visual Studio 2013 Pro. Thanks See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog box. ** * ** Exception Text ** * **** System.MissingMethodException: Method

C# and Excel Interop issue, Saving the excel file not smooth

旧城冷巷雨未停 提交于 2019-11-30 18:42:50
I could Open and Write to the excel file, but when I try to save the file by passing a path to it, the save operation prompts with the Save dialog. I was expecting it to quitely Save the file at the specified path The code is as below: excelApp.Save(exportToDirectory); excelApp.Quit(); where, exportToDirectory is: "C:\files\strings.xlsx". PS: I have already checked with the excel version and similar issue. Thanks You need to use Workbook.SaveAs instead of Application.Save : Excel.Application app = new Excel.Application(); Excel.Workbook wb = app.Workbooks.Add(missing); ... wb.SaveAs(@"C:\temp

C# = Why are Excel processes not ending?

折月煮酒 提交于 2019-11-30 18:09:32
I have the following code: private bool IsMousetrapFile(string path) { logger.Log(validateFileMessage + path); Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application(); Excel.Workbooks workbooks = xlApp.Workbooks; Excel.Workbook xlWorkBook = workbooks.Open(path, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing); Excel.Sheets worksheets = (Excel.Sheets)xlWorkBook.Worksheets; Excel.Worksheet ws = null; foreach (string sheet in

C# - Java interoperation

只愿长相守 提交于 2019-11-30 18:08:01
问题 Can you give me some pointers on making C# code and Java code interoperate? Let's define the interoperation as something simple: allow (from Java code) the instantiantion and method calling of a class defined in C#, and, possibly, the other way around as well. Is this even possible natively ? (i.e. without some proxy/skeleton interface mechanism) And finally, what proxy mechanisms can be used? (i.e. are supported by both language realms) 回答1: I've used IKVM to accomplish this successfully.