Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact


Calling C++ DLL from C#


Calling C++ DLL from C#

Author
Message
nicegal
nicegal
Forum God
Forum God (3.1K reputation)Forum God (3.1K reputation)Forum God (3.1K reputation)Forum God (3.1K reputation)Forum God (3.1K reputation)Forum God (3.1K reputation)Forum God (3.1K reputation)Forum God (3.1K reputation)Forum God (3.1K reputation)

Group: Forum Members
Posts: 11, Visits: 17
I have made a C++ DLL. Now I am calling it in my C# Code. I have written the following code:



using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.InteropServices; //For DllImport

namespace ExternCShar

{

class Program

{

[DllImport("MathFuncsDll.dll", CharSet = CharSet.Auto)]

public static extern double Add(double a, double b);



static void Main()

{



Console.WriteLine(Add(2.3, 4.5));

}

}

}







Now when I run this, the following error is generated:



Debug Error!



Program: ...



R6034

An application has made an attempt to load the C Runtime library without using a manifest.



This is an unsupported way to load Visual C++ DLLs. You need to modify your application to build with a manifest.



For more information, see the "Visual C++ Libraries as Shared Side-by-Side Assemblies" topic in the product documentation.











What should I do avoid this error?







Thanks.



Bina Khan.
C1JohnAdams
C1JohnAdams
Forum God
Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)Forum God (3.5K reputation)

Group: Forum Members
Posts: 22, Visits: 54
Hi Bina,

In order to correct the error you need to embed/include manifest in your application. Please rebuild your application to include a manifest. Building an application with Visual Studio automatically puts the manifest into the resulting .exe or .dll file. If you are building at the command line, use the mt.exe tool to add the manifest as a resource. Use resource ID 1 if you build an .exe, and resource ID 2 if you build a .dll.

If you want yo know how to embed a Manifest in VC++/C++ application then please visit the following link:http://msdn.microsoft.com/en-us/library/ms235591.aspx

Hope this helps Smile

Regards,

John Adams

ComponentOne LLC

jennifer2
jennifer2
Forum God
Forum God (419 reputation)Forum God (419 reputation)Forum God (419 reputation)Forum God (419 reputation)Forum God (419 reputation)Forum God (419 reputation)Forum God (419 reputation)Forum God (419 reputation)Forum God (419 reputation)

Group: Forum Members
Posts: 1, Visits: 2
Thanks for post. It’s really informative stuff.I really like to read.Hope to learn a lot and have a nice experience here! my best regards guys!


646-204 | 220-701 | 350-030 | 70-642

Rosemarry
Rosemarry
Forum God
Forum God (610 reputation)Forum God (610 reputation)Forum God (610 reputation)Forum God (610 reputation)Forum God (610 reputation)Forum God (610 reputation)Forum God (610 reputation)Forum God (610 reputation)Forum God (610 reputation)

Group: Forum Members
Posts: 2, Visits: 3
It is very important to understand that images are not technically "part" of the web page file, they are separate files which are inserted into the page when it is viewed by a browser. So a simple web page with one image is actually two files - the HTML file and the image file. The example on the right illustrates this.



In this example the two files are both located in the same folder. The HTML file includes an image tag which refers to image1.jpg.



When the HTML file is displayed in a browser, it requests the image file and places it on the page where the tag appears.

Rose
GO


Similar Topics


Reading This Topic


Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....

















A1VBCode Forums


Search