-
June 18th, 2012, 03:18 PM
#1
64-bit Managed Visual C++ DLL on .Net 2.0?
Moved from the C++ forum to this forum.
Is it possible to build a 64-bit managed Visual C++ dll targeting .Net 2.0 and then reference it from an ASP.NET application?
I need to re-use some legacy C++ code in an ASP.NET 2.0 application. My approach is to make a managed C++ dll that wraps the unmanaged code.
To begin, I created the simplest possible dll with one line of code to test the framework.
Header file:
namespace TestC {
public ref class Class1
{
public:
static String^ GetNonce();
};
}
Using Visual Studio 2010, I created a new C++ object assembly targeting framework version 2.0 and I add a 64-bit configuration. So far so good. But it won't build until I change the "Platform Toolset" to v100 in project properties.
Once I do that, it builds but when I reference the project from my ASP.NET project it tells me that the project or one of its dependencies references a later version of .Net. And indeed depends.exe indicates that it does depend on a v4.0 MSCOREE dll. But all of my reference paths and my framework version are to .Net 2.0.
So this is mystery #101.
If I ignore the error, it adds the reference to my application, and the reference initially shows up in the object browser, but when I build I get this error:
"The name 'TestC' does not exist in the current context"
and the reference is then removed from the object browser (but not the reference list). Based on this I assume I can't use the reference (so why did it let me add it?)
Theorizing it might be the toolset, I turn the toolset back to v90 but then I can't build and it says I need to install Visual Studio 2008.
I then download Visual Studio 2008 express (visual c++ edition). Now it gives me this error:
error MSB8014: Execution path (C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\x86_amd64) could not be found.
I've searched several sites purporting to have a solution to this problem, apparently involving getting 64-bit compilers installed, but so far no luck.
Before I sink any more days into this mess, can any one point me in the right direction?
Many thanks in advance!
Snippet from project file:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A139F959-7345-4E8C-AEF6-01942CB7C9F1}</ProjectGuid>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<Keyword>ManagedCProj</Keyword>
<RootNamespace>TestC</RootNamespace>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|