5

I have a C++/CLI project that was created in VS2005. I'm hoping to run this in VS2010 (or 2012) as that is my main IDE and I need to modify some things in the C++/CLI project as well and its irritating to have to switch back and forth to vs2005 to recompile, copy etc. The other important reason is my projects running in VS2010/2012 are in .NET4 so there is no option to move everything on to VS2005.

The project has dependencies on unmanaged third party libraries that themselves have dependencies on the debug versions of the c++ redistributable libraries (msvcr80.dll, msvcm80.dll, msvcp80.dll)

When I first ran the upgraded project I received 'specified module could not be found' -

It was then I noticed the cli project is being compiled against the later versions of msvc (msvcr90.dll)

cli assembly dependencies as per depends; vs2005 on left vs 2008 on right

enter image description here

Is there any way to make a later version of VS compile using the 2005 libraries?

update its not vital which one it compiles against (and may not be possible anyway) but is it possible to run and debug both side by side? When I try to run the compiled project I get this error message:

enter image description here

I've tried copying the manifest file from the vs2005 project to the vs2010 project but this does not work (same error message). I also disabled the embedded manifest and replaced the generated .manifest file with the one from vs2005 and this does not work either.

update2 I've got past this error by specifying the msvcr libraries in the manifest:

<dependentAssembly>
      <assemblyIdentity type='win32' name='Microsoft.VC80.DebugCRT' version='8.0.50727.762' processorArchitecture='x86' publicKeyToken='1fc8b3b9a1e18e3b' />
    </dependentAssembly>

however now when I run my application one of the third party libraries throws an AccessViolationException - Attempted to read or write protected memory when I try to use one of the methods. This code otherwise works fine in vs2005.

wal
  • 17,409
  • 8
  • 74
  • 109
  • downvoter pls explain ? – wal Jun 02 '13 at 03:36
  • Generally, this is not a problem when different parts of application depend on VC 2005 and 2008. Both runtime libraries should be installed to run such program. – Alex F Jun 02 '13 at 06:03
  • and for running in the context of visual studio, ie debugging ? – wal Jun 02 '13 at 09:47
  • One version of the C++ compiler (CL.EXE) is linked with one version of MSVCRT.LIB (triggered by the /MD option, implicitely triggered by the /clr option). This version of MSVCRT.LIB will link your application at runtime with a specific version of the MSVCRT DLL (MSVCRT110.DLL for VS2012, MSVCRT100.DLL for VS2010, etc.). You can't change that. If you want to use a more recent version of Visual Studio with managed C++ code, you'll have to deploy the adequate version of the MSVC runtime. – Simon Mourier Jun 12 '13 at 10:18
  • @SimonMourier thanks. and what about running (production and in visual studio) alongside third party libs that are built against msvcrt80.dll? – wal Jun 12 '13 at 13:04
  • It should be fine as long as you don't do funny things, such as pass CRT objects from one version to the other. http://msdn.microsoft.com/en-US/library/ms235460.aspx – Simon Mourier Jun 12 '13 at 13:18
  • @SimonMourier debugging (or running within VS) does not work. I get an error `an application has made an attempt to load the C runtime library without using a manifest`. I copied the manifest (Microsoft.VC80.DebugCRT.manifest) from my working VS2005 project into my 2012 and 2010 projects but I still get this error. any ideas? – wal Jun 12 '13 at 13:41
  • Difficult to say from here, but this is a very common message (google can help). Somehow, Windows is missing a manifest for one of the version of MSVCRT (maybe 8, 9, 10, 11) implicitly or explicitly required by the application (maybe a DLL or the EXE). Check this out: http://blogs.msdn.com/b/nikolad/archive/2005/06/09/427101.aspx – Simon Mourier Jun 12 '13 at 14:18
  • @SimonMourier ok after getting past the manifest problem by specifying `Microsoft.VC80.DebugCRT` in the exe manifest I now have a new problem: I am getting an `AccessViolationException - Attempted to read or write protected memory...` thrown from the *third party library* where in the 2005 version the same code works. now what? giveup? :( – wal Jun 13 '13 at 00:59
  • @wal - well, that sounds bad, yes. – Simon Mourier Jun 13 '13 at 07:21
  • @SimonMourier see my answer, I was able to compile against a different version fairly easily - given what you said before regarding cl.exe I assume then it must be using the cl.exe that ships with vs2005? – wal Jun 13 '13 at 12:57
  • Well. I learned something today :-) Does that fix your AccessViolationException? That's surprising also. – Simon Mourier Jun 13 '13 at 13:27
  • @SimonMourier it didnt fix it per se because that was when I was mixing both vc100 and vc80. now the output of the vs2010 produces a .net cli/c++ assembly that is linked against vc80 only. (and this assembly does not throw any `AccessViolationException` i guess it should be identical to doing it in vs2005) happy days! – wal Jun 13 '13 at 13:40

3 Answers3

4

I have since discovered Daffodil for Visual Studio which does exactly what I need, namely compile against vc80 in visual studio 2010. After installation the Platform Toolset dropdown gets a few more options:

nb, you still need to have the relevant version of Visual Studio installed, eg if targeting vc80 you need vs2005. nb2, Intellisense is broken in vs2010 for cli/c++ which is a major letdown after the amount of time researching getting the project to work on vs2010

enter image description here

Community
  • 1
  • 1
wal
  • 17,409
  • 8
  • 74
  • 109
0

Have you considered making a manifest for the application? I mean, the error message says that the problem is that the manifest is lacking, so perhaps it will be sufficient to create a manifest (either through the project settings) or adding a hand written one?

See: Problem loading RT without Manifest

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
Grezgory
  • 316
  • 2
  • 4
0

From http://www.davidlenihan.com/2007/07/winsxs.html

"So how does an application know what version of a DLL it needs to load? That is where a "manifest" comes into play. A manifest is an XML file that contains information used to create the directory in C:\Windows\winsxs so that a particular DLL can be loaded."

Nothing
  • 99
  • 12