Maintaining C++ code that uses MFC

  • (2 Pages)
  • +
  • 1
  • 2

23 Replies - 1925 Views - Last Post: 25 January 2016 - 09:06 AM

#1 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 644
  • View blog
  • Posts: 4,844
  • Joined: 25-December 13

Maintaining C++ code that uses MFC

Posted 07 January 2016 - 08:01 AM

I'm maintaining a C++ program that uses MFC classes. I am not a MFC programmer and know enough C++ to do updates and debugging.
I am using VS2005 to make updates. I distribute the dlls and .exe file via a zip file that users download and unzip to use the program. The zip is about 4MB.
Some of the users have IDEs installed on their PCs. When they try to execute the code, they get an error about side-by-side configutation is wrong. That seems to be caused by a mismatched dll problem.

One user suggested I download VS2015 and use it for my changes. I downloaded and installed VS2015 and created a new version of the program that works on my PC (Win10 Pro with the IDE) but fails on my wife;'s PC (Win10 Pro without an IDE). The failure was due to 3 missing dlls in the mfc 140 series. I copied the 3 dlls from my PC to the program's folder on her PC and the program worked.

My question: Can I use VS2015 to generate a program that uses older versions of the MFC dlls? The PC without the IDE has MFC 100 series dlls in Windows\system32.

Is there a better place to ask this question?

Thanks,
Norm

This post has been edited by NormR: 07 January 2016 - 08:02 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Maintaining C++ code that uses MFC

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13560
  • View blog
  • Posts: 54,109
  • Joined: 12-June 08

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 08:11 AM

In VS you should have an option to click on references and have them 'copy local' or embed them.
Was This Post Helpful? 0
  • +
  • -

#3 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 644
  • View blog
  • Posts: 4,844
  • Joined: 25-December 13

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 08:18 AM

Is that acceptable or possible: Copy MS dll files into my exe file? Or are you suggesting I copy MS files into my zip file? I think it would be better if the IDE created code that referenced the mfc 100 series of dlls. Including the dlls would double the size of the zip file.

I build the zip file with a batch file that gathers up the pieces the program needs and puts them into the zip file.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13560
  • View blog
  • Posts: 54,109
  • Joined: 12-June 08

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 08:23 AM

If you are not looking to have to build some redistribute that provides the files, but you need to use them, what other options are you looking at? Not many I would suspect.
Was This Post Helpful? 0
  • +
  • -

#5 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 644
  • View blog
  • Posts: 4,844
  • Joined: 25-December 13

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 08:40 AM

Thanks again for the response.
What I was trying to get around was the side-by-side configuration problem. That problem only seems to happen with users that have an IDE. There are several hundred users of the program and the ones that have complained about the side-by-side problem have admitted to having an IDE. I was trying to make the minimum changes to my development environment to accommodate them without impacting any of the others. So far VS2015 has only required one source file change out of the 300+ source files in the program and that was in a file that has not changed in years so I can an a copy of that file for the VS2015 IDE. The other files are shared between VS2005 and VS2015 so there is just one place for logic changes that both IDEs pickup.

I'm still trying to figure out my options. Right now it looks like if I use VS2015 I need to also send a package of MS mfc 140 series dlls. The VS2005 IDE created code uses the 80 series dlls which seem to be included in Win10.

This post has been edited by NormR: 07 January 2016 - 08:41 AM

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13560
  • View blog
  • Posts: 54,109
  • Joined: 12-June 08

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 08:43 AM

What is the exact 'side by side' error message?

Presumably if you have the DLLs the app needs, with the app so it doesn't go traipsing off to find other similarly named files but of a different version, you should be fine. At worst you burn a little time when you unshelve your project, click a few options on the references, recompile, test on a problem pc, and see what's up.
Was This Post Helpful? 0
  • +
  • -

#7 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 644
  • View blog
  • Posts: 4,844
  • Joined: 25-December 13

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 09:31 AM

Here's a copy of the message a user sent me:

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#8 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13560
  • View blog
  • Posts: 54,109
  • Joined: 12-June 08

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 09:39 AM

Mkay.. and what does the event log say for that error?
Was This Post Helpful? 0
  • +
  • -

#9 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 644
  • View blog
  • Posts: 4,844
  • Joined: 25-December 13

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 01:47 PM

Is this what you are asking about?

ERROR: Component identity found in manifest does not match the identity of the component requested.
Reference is Microsoft.VC80.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.762".
Definition is Microsoft.VC80.MFC,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="8.0.50727.6195".
ERROR: Activation Context generation failed.
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13560
  • View blog
  • Posts: 54,109
  • Joined: 12-June 08

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 01:53 PM

ARe you embedding the manifest in the project settings?
Was This Post Helpful? 0
  • +
  • -

#11 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5923
  • View blog
  • Posts: 20,254
  • Joined: 05-May 12

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 02:06 PM

Read Redistributing the MFC Library

Read Redistributing the MFC Library
and Redistributing Visual C++ Files
Was This Post Helpful? 1
  • +
  • -

#12 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 644
  • View blog
  • Posts: 4,844
  • Joined: 25-December 13

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 02:13 PM

Quote

ARe you embedding the manifest in the project settings?
Sorry, I don't know what that means.
As I said, I'm not a MFC programmer. I took over the EasyBridge project when the author abandoned it. I have had minimal exposure to using the IDE's settings. I'm using what the original author set up and what was converted by another programmer that converted the project from VC++6 to VS2005 several years ago.

I'm looking for the easiest way to support a very few users that happen to have an IDE. As far as I know the other users have not had this problem. Hopefully as I play around with the IDE's settings I can learn more about how to configure it to create the exe and dll files I am putting into the zip file for others to use.

Thanks for your help.
Norm

This post has been edited by NormR: 07 January 2016 - 03:59 PM

Was This Post Helpful? 0
  • +
  • -

#13 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5923
  • View blog
  • Posts: 20,254
  • Joined: 05-May 12

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 07:15 PM

View PostNormR, on 07 January 2016 - 04:13 PM, said:

I'm looking for the easiest way to support a very few users that happen to have an IDE.


Right now that looks like it'll be as easy as trying to make a 6NT bid when you have less than 13 points between your hand and the dummy.

The right thing to do is redistribute the application with the necessary binaries appropriate for the version that you are compiling against.

You maybe able get around this by switching the your build settings to go statically linking all the libraries. Static link MFC. Static link the C runtime library. If you are using any 3rd party libraries, pray that they have a static link option that also uses a statically link C runtime.
Was This Post Helpful? 0
  • +
  • -

#14 NormR  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 644
  • View blog
  • Posts: 4,844
  • Joined: 25-December 13

Re: Maintaining C++ code that uses MFC

Posted 07 January 2016 - 07:47 PM

Quote

statically linking all the libraries.

I'm not sure how to do that. When I changed the /MD option to /MT (or visa versa) I got an #error from a source file where it an #ifdef statement detected that option and complained. I don't remember exactly where or what the message was and will have to retrace my steps to get the exact details.
Was This Post Helpful? 0
  • +
  • -

#15 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 5923
  • View blog
  • Posts: 20,254
  • Joined: 05-May 12

Re: Maintaining C++ code that uses MFC

Posted 08 January 2016 - 05:57 AM

Very likely, there is also a define that needed to be removed or undefined that indicates whether the code is being dynamically linked.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2