interop

Call C# dll function from C++/CLI

こ雲淡風輕ζ 提交于 2019-11-28 12:02:00
I have a C# dll. The code is below: public class Calculate { public static int GetResult(int arg1, int arg2) { return arg1 + arg2; } public static string GetResult(string arg1, string arg2) { return arg1 + " " + arg2; } public static float GetResult(float arg1, float arg2) { return arg1 + arg2; } public Calculate() { } } Now, I am planning to call this dll from C++ on this way. [DllImport("CalculationC.dll",EntryPoint="Calculate", CallingConvention=CallingConvention::ThisCall)] extern void Calculate(); [DllImport("CalculationC.dll",EntryPoint="GetResult", CallingConvention=CallingConvention:

How do I get an entire column in used range?

余生长醉 提交于 2019-11-28 12:00:29
I am trying to get a column, but limiting it to used range... public static Excel.Application App = new Excel.Application(); public static Excel.Workbook WB; WB = App.Workbooks.Open("xxx.xls", ReadOnly: true); var sheet = (WB.Sheets[1] as Excel.Worksheet); // returns 65536 rows, I want only 82 (used range) sheet.get_Range("F:F"); sheet.UsedRange.get_Range("F:F").Rows.Count; // 65536 How can I get it? You can use sheet.UsedRange.Columns[6, Type.Missing].Rows.Count or this sheet.UsedRange.Columns["F:F", Type.Missing].Rows.Count Charles Williams Sounds like you want the Application.Intersect of

Overloads in COM interop (CCW) - IDispatch names include suffix (_2, _3, etc)

廉价感情. 提交于 2019-11-28 11:46:20
I have a managed assembly containing a few classes, and those classes have overloaded methods. I expose the assembly to COM/IDispatch callers via [ComVisible(true)] ..and also setting the proper Guid, on the assembly itself. I do not define an explicit interface for the COM interop. It's all done dynamically. I run regasm.exe /codebase on the managed DLL and it registers it for COM interop. When I run OleView, I can see the ProgId's of the various classes in the assembly. But, browsing into those ProgIds, and expanding IDispatch node, there is no TypeLib information for these classes. Even so,

Set custom document properties with Word interop

亡梦爱人 提交于 2019-11-28 11:26:55
I want to set some custom document properties of a word document I'm creating in my C# code. To do this, I followed this MSDN article and came up with this code: using Word = Microsoft.Office.Interop.Word; // Version 12.0.0.0 word = new Word.Application(); word.Visible = false; Word._Document doc = word.Documents.Add(ref missing, ref missing, ref missing, ref missing); logger.Info("Setting document properties"); Core.DocumentProperties properties = (Core.DocumentProperties)doc.BuiltInDocumentProperties; properties["Codice_documento"].Value = args[3]; properties["Versione_documento"].Value =

C# get the list of unmanaged C dll exports

吃可爱长大的小学妹 提交于 2019-11-28 11:25:27
I have a C dll with exported functions I can use the command-line tool dumpbin.exe /EXPORTS to extract the list of exported functions, and then use them in my C# code to (successfully) call these functions. Is there a way to get this exported-functions-list directly from .NET, without having to use an external command-line tool? Thanks As far as I know there is no class in the .Net Framework that provides the information you need. However you can use the platform invocation services (PInvoke) of the .Net platform to use the functions of the Win32 dbghelp.dll DLL. This DLL is part of the

Hosting Windows Forms UserControl into Silverlight application

跟風遠走 提交于 2019-11-28 11:15:53
问题 I've a DLL written in Windows Forms. I need to host one UserControl from this DLL to my silverlight project. Is this possible? In WPF, this is possible using WindowsFormsHost : <WindowsFormsHost Name="m_WindowsFormsHost" Height="800" Width="900" > <winform:PlayerWindowControl /> </WindowsFormsHost> I want to do this in silverlight. 回答1: There is no similar support, nor does it seem likely any would be added, as Silverlight tries to be cross-platform. If you want this feature, then you should

Excel dll for Microsoft.Office.Interop.Excel

冷暖自知 提交于 2019-11-28 11:15:35
We want to use Microsoft.Office.Interop.Excel in our web application. Everything works fine on our local machines, but on our test machine we're running into problems. It has neither Visual Studio nor Office installed on it. We're using .NET framework 2.0 and the server is running on Windows Server 2003 with IIS6. Is there a dll that needs to be installed on the machine or added to the bin of the web application? You will need to have MS Office and the Office Interop assemblies installed on your server in order for that to work. I'm pretty sure that you will need to have Office installed on

marshalling a struct containing string

拜拜、爱过 提交于 2019-11-28 10:57:08
问题 i basically want to take int name and string age from user in c# and send it to dll method written in c which take int and char[50] arguments in it and return string .i created following scenario but i am failed ,any body has the code i have a dll developed in c which ahas a structure struct Argument { int age; char name[50]; } ; and a method extern "C" { __declspec(dllexport) Argument FillData(Argument data) { Argument mydata; mydata.age=data.age; for(int i=0;i<=sizeof(data);i++) { mydata

Error when instantiating .NET/COM interop class via classic ASP

可紊 提交于 2019-11-28 10:56:26
问题 I am having a problem when trying to instantiate a C# .NET class that's been exposed to COM in a classic ASP application. I've used tlbexp to generate a typelib and registered it in Component Services; now when trying to create the object as such: Server.CreateObject("The.Class.Name") I am getting the error: Server object error 'ASP 0177 : 80131534' Server.CreateObject Failed I've searched around online for information on this error, and found numerous discussions but no solution. The error

Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE))

孤者浪人 提交于 2019-11-28 10:41:28
I am trying to convert a .xls file to an .xlsx file on the server-side using Microsoft.Office.Interop.Excel.Workbook class as follows: workBook.SaveAs("FILENAME_HERE", XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange, Microsoft.Office.Interop.Excel.XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing, Type.Missing, Type.Missing); and I get the following error: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80080005