Build a VC++ library that is not COM

TongZ
TongZ used Ask the Experts™
on
Dear all,
     I have a VC++ project that is currently a COM library that is being used by another VB.NET project. Apparently, COM is a headache in terms of version and registration. So I am going to build it into a non-Com library that doesn't require register. My questions are below:

    1.  I am using MS VC++ 2005 pro compiler. I made a new project that is CLR+class Library. I plan to add codes from the original project into this new one in the hope of starting a clean new project that is .NET managed DLL (so it is not com), is this a viable way to do it?

    2. right after I created the project, I did a compile, it gives this error:
fatal error C1189: #error: Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version. Please #define _AFXDLL or do not use /MD[d]

    Any suggestions, please.
    Thanks.

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
AndyAinscowFreelance programmer / Consultant
Commented:
I hope you realise that C++ .NET is NOT the same programming language as MFC / C++.  They might have similar names and look similar.
What you are attempting is not a matter of a few minutes work of copying/pasting, you will have a lot of recoding to do.   Having said that please do not take it as any indication that what you are doing is not reasonable, it may well be your best option.

Author

Commented:
I just noticed that my post got into this domain of MS Access, should I be reposting to another section or something?

BTW, AndyAinscow, thanks for the headsup on this. I don't really need MFC, but I don't know how to make the compile to not use [md]
AndyAinscowFreelance programmer / Consultant

Commented:
It isn't just MFC, that is a wrapper for a lot of window specific things in C++ - which is not .net.


2. right after I  created the project, I did a compile, it gives this error:fatal  error C1189: #error: Building MFC application

If you do not require MFC then start again with a new project and do not select an MFC based project.
11/26 Forrester Webinar: Savings for Enterprise

How can your organization benefit from savings just by replacing your legacy backup solutions with Acronis' #CyberProtection? Join Forrester's Joe Branca and Ryan Davis from Acronis live as they explain how you can too.

If you are truly going to translate from COM to .NET, that is extensive work.

I just did the same not long ago.

Your best option is to start a clean .NET project and use a design based on your COM classes.  Then reimplement as you go in .NET.

Just dumping the old code into the project will give you lots of compiler headaches etc.  It is much better to keep the COM code as a reference and use it to implement a pure .NET version.

Author

Commented:
Hey guys,

Author

Commented:
Hey guys,
      I started a new VC++ project as CLR then as a class library. Selecting CLR is supposed to be a .NET flavor project, right? So I am gradually adding original code into this project while taking care to get rid of the callback functions that passing objects etc. Would like to get some confirmation that this would work to create a non-COM VC++ DLL that can be called directly through declaration in a VB.net project.
      Thanks.
It sounds like you are on the right track
AndyAinscowFreelance programmer / Consultant

Commented:
Yes.
clr means common runtime language  which is the .net environment.
A  .net class should be language independant, ie. written in C++.net and used by VB.net shouldn't be a problem

Author

Commented:
I would like to award 50 points each to:

AndyAinscow and HalfAsleep

Their combined comments gave me the full picture.

I consider this question resolved.
AndyAinscowFreelance programmer / Consultant

Commented:
Click on the 'split' link next to the comments and select the comments to give the points to - you are expected to close the questions yourself.

Author

Commented:
This is a categorical question, so both AndyAinscow and HalfAsleep provided information that contribute to the overall understanding of the subject.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial