Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've written a small utility program that "works on my machine" (Win7 64 w/VS2012).
When I copy the exe, support dll and .exe.config files to another Win7 64 (Office 2012) system (attempted on both physical and VM systems) it fails to execute with a dialog showing info (below).
Bing searches seem to imply that my most likely cause is incorrect .NET version installed w.r.t. build target. .NET 4.0 is installed and the build target is .NET 4 Client.
Does the fact that the build environment has .NET 4.5 installed mean that targeting .NET 4 Client really will end up requiring 4.5? If so, is there a way to build to really target .NET 4?

Any other hints/suggestions?
Thanks

More info:
I tried installing .NET 4.5.1 on the VM and it made no apparent difference.

EDIT #2:
Still more info:
I copied the FUSLOGVW (Assembly Binding Log Viewer) containing-folder from the VS install on the build system over to the VM, and executed it. Logging the bindings shows a binding failure for the
applicationName.resources, Version=1.0.0.0
The resources should be built into the exe, there is no separate resources assembly in the project\bin\Release folder.
So what am I missing?

EDIT #3:
I'm beginning to suspect it has to do with the Culture:
The application shows (in the Assembly Binding Log) as Culture=neutral
but it is looking for resources as Culture=en-US
In the AssemblyInfo.cs and Project settings I do not specify any culture. Just like other programs I've written... And it works on the development system just launching the exe directly.

I tried setting the NeutralResourcesLanguage attribute and <UICulture> in the .csproj file. This caused the resources to be built into a satellite assembly under a en-US folder, however, that then caused an exception to be thrown on the development system when the MainWindow.xaml.cs was initializing.


Problem signature:
  Problem Event Name:	CLR20r3
  Problem Signature 01:	XXXX YYYY ZZZZ.exe
  Problem Signature 02:	1.0.0.0
  Problem Signature 03:	532ce19e
  Problem Signature 04:	PresentationFramework
  Problem Signature 05:	4.0.0.0
  Problem Signature 06:	4ba1f8db
  Problem Signature 07:	f99
  Problem Signature 08:	cc
  Problem Signature 09:	System.InvalidOperationException
  OS Version:	6.1.7601.2.1.0.256.48
  Locale ID:	1033
  Additional Information 1:	6404
  Additional Information 2:	640404062cbb864fc4242ad6a13f7c84
  Additional Information 3:	1237
  Additional Information 4:	1237d14f88a4e19132828c7daa02ae3b
Posted
Updated 24-Mar-14 15:44pm
v4
Comments
ZurdoDev 24-Mar-14 21:25pm    
Do you get anything more in the event viewer?
Matt T Heffron 24-Mar-14 21:45pm    
Nothing intesting in the event viewer.
I've added more suspicions...

Yes, if the project is targeting .NET 4.5, you have to have .NET 4.5 installed on the machine that's going to run the code.
 
Share this answer
 
Comments
Matt T Heffron 24-Mar-14 21:03pm    
I'm targeting .NET 4.0, and .NET 4.0 (and subsequently 4.5.1) are installed.
Dave Kreskowiak 24-Mar-14 22:30pm    
'PresentationFramework' tells me this is a WPF app, correct?

Try adding a handler for the 'DispatcherUnhandledException' event in App.xaml:
<application x:class="MyApp" startupuri="UI\Pages\StartPage.xaml" dispatcherunhandledexception="Application_DispatcherUnhandledException">

In the event handler for it, show a messagebox with the exception message. You may have to show message boxes for InnerExceptions, so make it a recursive method.
Matt T Heffron 25-Mar-14 13:47pm    
Thanks, that led to what appears to be the solution.
+5
Despite what I'd found before, it seems it had to do with a WPF Binding!
Adding the DispatchUnhandledException event handler (thanks Dave Kreskowiak!) showed that it was attempting to do a TwoWay binding to a read only property.
I added a Mode attribute and now it works!
HTML
<Run Text="{Binding Path=FilePath, Mode=OneWay, FallbackValue=C:/abc/def/foo.csv}" />

But why would the Binding in the Run (in a TextBlock) not be OneWay by default?
And why didn't it fail on the development system?
 
Share this answer
 
v2
Comments
Dave Kreskowiak 25-Mar-14 15:01pm    
I found that little trick about 6 months ago. It came in very handy with code that was running in a Task and exploding.

As for the rest, I have no idea why it worked before and not after deployment. I've only done a few WPF apps so far and never ran into the problem.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900