interop

Possible to call a managed DLL from unmanaged C++?

安稳与你 提交于 2019-11-29 10:10:11
Is it possible to call CLR DLL (one for example which is made with C#) from unmanaged C++ code? I need a DLL that is not managed to call into it somehow, maybe even via some proxy C++ process that is built with C++ / CLI? The CLR DLL would have to be built as a COM visible assembly. If you have control of the C#, it's a simple rebuild, otherwise, is pretty much impossible to use it directly. @SWeko gave you the best answer if you can modify the original DLL and your unmanaged code can rely on having access to a COM apartment (either its own thread with ::CoInitialize() called or the calling

How can I debug a VB6 project that has a .net interop project which uses an app.config file?

痞子三分冷 提交于 2019-11-29 09:38:06
I have a .net interop project that uses an app.config file. When I am running the VB6 project that is using the interop control in Debug mode, the ConfigurationManager cannot find the app.config file. When I make the VB6 project into an exe and rename the app.config file to (VB6 binary name).exe.config, the ConfigurationManager can find the file. Is there a way to rename the app.config file or change a setting so ConfigurationManager can find the app.config file while VB6 is running in debug mode? A dirty hack is to place the app.config file into the VB6 folder and rename it to vb6.exe.config

“Bad binary signature” in ASP.NET MVC application

别等时光非礼了梦想. 提交于 2019-11-29 09:31:31
We are getting the error above on some pages of an ASP.NET MVC application when it is deployed to a 64 bit Windows 2008 server box. It works fine on our development machines, though these are 32 bit XP. Just wondered if anyone had encountered this before, and has any suggestions? Details as follows: Bad binary signature. (Exception from HRESULT: 0x80131192) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime

C++/CLI String Conversions

南楼画角 提交于 2019-11-29 08:43:05
I found this really nice piece of code that converts a string to a System:String^ as in: System::String^ rtn = gcnew String(move.c_str()); // 'move' here is the string I'm passing rtn back to a C# program. Anyways, inside the function where this code exists, I'm passing in a System::String^ . I also found some code to convert a System:String^ to a string using the following code: pin_ptr<const wchar_t> wch = PtrToStringChars(cmd); // 'cmd' here is the System:String size_t convertedChars = 0; size_t sizeInBytes = ((cmd->Length + 1) * 2); errno_t err = 0; char *ch = (char *)malloc(sizeInBytes);

In C#, how do I invoke a DLL function that returns an unmanaged structure containing a string pointer?

北战南征 提交于 2019-11-29 08:06:05
I have been given a DLL ("InfoLookup.dll") that internally allocates structures and returns pointers to them from a lookup function. The structures contain string pointers: extern "C" { struct Info { int id; char* szName; }; Info* LookupInfo( int id ); } In C#, how can I declare the structure layout, declare the Interop call, and (assuming a non-null value is returned) utilize the string value? In other words, how do I translate the following into C#? #include "InfoLookup.h" void foo() { Info* info = LookupInfo( 0 ); if( info != 0 && info->szName != 0 ) DoSomethingWith( info->szName ); // NOTE

Excel.Range.Find method

烈酒焚心 提交于 2019-11-29 07:54:51
I am using Excel interop object and trying to find a date in a specified range by below method Excel.Range rngFind = WS.get_Range(strFromRange, strToRange).Find(strFind, Type.Missing, Excel.XlFindLookIn.xlFormulas, Excel.XlLookAt.xlPart, Excel.XlSearchOrder.xlByRows, Excel.XlSearchDirection.xlNext, false, false, false); but i get rngFind as null always my strFind = "Sep-08" i tried with both Excel.XlFindLookIn.xlFormulas and Excel.XlFindLookIn.xlValues my excel file looks like this Sep-08 Oct-08 Nov-08 Dec-08 Jan-09 Feb-09 Mar-09 Apr-09 May-09 Jun-09 Jul-09 where as wheni click on Sep-08 cell

Converting images from word document into bitmap object

早过忘川 提交于 2019-11-29 07:39:02
As per project requirement we need to convert images from word document into bitmap object. To achieve this we tried to convert inlineshape object from Microsoft.Office.Interop.Word dll into bitmap. However unable to get success, getting clipboard object as null. Please find the code which we tried as below; using System.Drawing; using Microsoft.Office.Interop.Word; namespace WordApp1 { class Program { static void Main(string[] args) { Application wordApp = (Application)System.Runtime.InteropServices.Marshal.GetActiveObject("Word.Application"); Documents documents = wordApp.Documents; Document

Microsoft.Office.Interop.Excel doesn't work on 64 bit

一曲冷凌霜 提交于 2019-11-29 06:52:09
I've encountered a problem when developing on MS Visual Web Developer 2008 Express Ed. Developing ASP.NET C# on Windows7 64 bit OS. I'm trying to open an Excel document, but it gives me Old format or invalid type library. (Exception from HRESULT: 0x80028018 (TYPE_E_INVDATAREAD)) I did configured the build to all processors (Any CPU, x64, x86) but it doesn't work. I searched the answer on the internet but couldn't find out how to handle it. The weird thing is the same code worked on the same system when I developed on Microsoft Visual C# 2010 Express! how come? isn't it the same dll working

Printing using Word Interop with Print Dialog

给你一囗甜甜゛ 提交于 2019-11-29 06:42:30
I'm trying to print a word doc from my C# code. I used the 12.0.0.0 Word Interop and what i'm trying to do is to get a Print Dialogue pop up before the document prints. I'm not 100% sure of the syntax of all of this as I can't get my code to work :( Any ideas? Thanks in advance! McAden It should be something along the lines of: object nullobj = Missing.Value; doc = wordApp.Documents.Open(ref file, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj); doc

Excel Interop - Draw All Borders in a Range

こ雲淡風輕ζ 提交于 2019-11-29 06:07:40
I see from Microsoft's documentation that I can access the particular border edges of a cell using the 'xlBordersIndex' property and for example set the border style for the left edge of a cell: range.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlEdgeLeft].LineStyle = Excel.XlLineStyle.xlContinuous; But what if I just want to draw all borders? I have tried range.BorderAround2(); but that just draws a box around the range itself, which I understand. So then I tried range.Cells.BorderAround2(); thinking that it would go through each of the cells within the range and place all borders