A1VBCode Forums

Calling C++ DLL from C#


http://www.a1vbcode.com/vbforums/Topic23849.aspx

By nicegal - 12/25/2007

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.
By Rosemarry - 6/30/2010

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.