Visual Basic Code , VB.NET Code, VB Code
  Home   :  Code   :  Forums   :  Submit   :  Mailing List   :  About   :  Contact
A1VBCode Forums
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      

Home » .NET Programming (VB 2010 or earlier) » C# » Calling C++ DLL from C#


Calling C++ DLL from C#Expand / Collapse
Author
Message
Posted 12/25/2007 10:00:35 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 12/25/2007 9:59:20 AM
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.
Post #23849
Posted 5/29/2008 10:24:10 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 9/24/2008 3:17:07 AM
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

Regards,
John Adams
ComponentOne LLC

Post #25052
Posted 6/19/2010 7:22:05 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 9/21/2010 1:05:33 AM
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
Post #29359
Posted 7/1/2010 4:02:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 7/1/2010 5:05:17 AM
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
Post #29393
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 1 (1 guest, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Admin, Mod, Mark, Keithuk

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 2:16pm