Cannot run 32bit compiled WPF applications on Windows 7 64bit - wpf

I created a WPF project in VS2008 and compiled it with Any CPU, x64 and x86. Any CPU and x64 works, but compiling to x86 the application is hanging when running through VS2008 and crashing when running without debugging. Debugging it with WinDbg I can see a StackOverflowException and sometimes a MissingMethodException relating to WPF methods.
Common sense is telling something here that the CLR is not loading the correct assemblies or something when running 32bit WPF apps. I tried reinstalling .NET Framework 3.5 SP1, but it does not fix the problem. I don't know how to go about checking if the correct assemblies are loaded or used.
Any ideas?
UPDATE: Not a real solution but the best I could do quickly was to reinstall Windows 7

Try to force the right compiler in all projects of your solution :
Properties
Build
Platform target

Try forcing Windows to always use the 32bit CLR and see if it still crashes:
C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Ldr64.exe setwow
-Oisin

I think I ran into this issue also. If I remember correctly, I had a problem where a dependency was compiled for x86 and the main app was compiled for x64, or the other way around. i.e. say I had a library and an app with a main function. I think they both need to compiled the same way. i.e. I don't think you can mix and match. This might not have been the exact same issue. I would go through all the projects in the solution make sure they all have the same settings.

Related

VS create winforms apps only with x86 configuration, why?

I have VS.NET 10.0.40219.1 SP1 in 2 computers and when I create a new C# Winform app only do it with Properties/Build/Platform x86, and the target let me choose AnyCpu/x64, but can't set it in the configuration (however, libraries work fine).
If I try to change it in the project file manually, I get a lot of nasty errors. Is this normal behavior, a bug or a problem in my installation?
P.D: When I change manually the project, this happend:
Warning 1 The OutputPath property is not set for project '*.csproj'.
Please check to make sure that you have specified a valid combination
of Configuration and Platform for this project. Configuration='Debug'
Platform='x86'. This error may also appear if some other project is
trying to follow a project-to-project reference to this project, this
project has been unloaded or is not included in the solution, and the
referencing project does not build using the same or an equivalent
Configuration or
Platform. c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets
When I reopen the project, ALL the references become invalid
It is normal for Visual Studio to create WinForms projects with just an x86 platform. I have no idea if that's because historically x86 was the only platform type or because x86 is the most commonly used value or for some other reason.
It's also normal to have problems when the project file is manually modified, try to avoid doing that where possible.
To create another platform configuration in a C# project
Select Build | Configuration manager
Select <New...> in the Active Solution Platform field
Select the new type you want
Click on OK
Visual Studio used to create AnyCPU apps by default. I think both VS2005 and VS2008 did this, though they may have changed it for VS2008. Here's what happened: a lot of AnyCPU apps ended up broken on 64-bit systems, because they were built with dependencies on 32-bit libraries. If you tried to run an AnyCPU app that had a 32bit dependancy on a 64bit system, you got a 64bit process that would crash as soon as it tried to load your 32bit dll.
To fix this, the default was changed to use the x86 option. If you want to use AnyCPU, you must now setup the environment for it.

Compiling 32-bit application using Visual Studio on a 64-bit machine

I'm trying to compile a simple 32-bit Hello World application written in C using Visual Studio 2010 on a 64-bit machine on a Windows 7 fresh install. I also installed the "Windows SDK for Windows 7 and .NET Framework 4" after installing Visual Studio.
I built the application selecting "Win32" as platform. It works on Windows 7 but if I run the application on my 32-bit machine with Windows XP Professional (fresh install also this, without softwares and Service Packs) it seems not working getting this error:
"This application has failed to start because msvcr100.dll was not found"
If it can be useful Dependency Walker detects 2 errors (see the linked picture for details):
"Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module."
"Error: Modules with different CPU types were found."
http://img820.imageshack.us/img820/4725/errordp.png (PIcture)
How can I solve it? Thanks!
The machine on which it is run needs the runtime libraries. See this MSDN information.
Don't trust Dependency Walker on this... It clearly shows your exe is 32 bit. Your problem is with the VC redistributables, which are the CRT dlls - look for vcredist_x86.exe in your VS installation. You should run it before you run your app.
Another option is to statically link the CRT. See the /MT option. Will make your exe larger, but save the vcredist stuff.
The problem here is the C runtime used by the compiled program is missing on the Windows XP machine. Visual Studio 2010 will by default us the 10.0 (msvcr100.dll) runtime which is not available on XP by default. You need to manually deploy the C runtime on your machine in order for your program to run.
You may want to read the following MSDN article which discusses the issues around deploying C applications built with Visual Studio 2010
http://msdn.microsoft.com/en-us/library/zebw5zk9.aspx
There may be additional 32 / 64 issues at work but this appears to be the primary problem
The answers about the runtime library are correct. Another possible solution is to link to the static runtime libraries rather than to the DLL versions. This way you can build an executable that you can drop onto any machine without extra deployment hassles.
It's a trade-off, but, without knowing more about your situation, it might be worth considering.

VS Studio 2008 VB.Net Winform - can it be run on a MAC?

Our company has a handful of Mac users. I recently built a Winform application and now my main user is using a Mac. Is it possible to run this application on a Mac? What would have to be done to convert it? If it is too much, I may just rebuild it is asp.net as a web application.
Thanks in advance!
JCC
Maybe. Many .Net programs can be compiled with mono as well, winforms usually is not a problem, but some libraries (e. g. MS Office libraries for editing Excel files). I am not sure about VB, as mono coders mostly use C#, but you can analyse your code with the Mono Migration Analyzer for portability to mono.
Depending a bit on features and controls used, it may run on Mono. Since you can run Mono on Windows as well it's rather easy to download and test it.
Your basic options are (from least intrusive to most intrusive, from the point of view of a Mac user):
Convert it to a web app.
Run it on a Terminal Server and have them use Remote Desktop.
Run the application in a virtual machine (VMWare or Parallels) that is running Windows.
Try to get it running under Mono.
If there isn’t a strong reason for it to be a desktop application, you really should be thinking in terms of web apps for new applications—at least, that’s an unwritten rule where I work.

Why does VS.NET attempt to include Microsoft.Windows.Design.Extensibility for WPF and ClickOnce?

I built a WPF application in VS.NET 2008 using ClickOnce deployment. It ran great on any machine that had VS.NET installed, but my business users received an error: "Unable to install or run the application. The application requires that assembly Microsoft.Windows.Design.Extensibility Version 3.5.0.0 be installed in the Global Assembly Cache (GAC) first."
I was surprised to discover that this dll is not part of the standard .NET 3.5 SP1 client installation, but somehow, my application thought it was needed. I checked my Publish tab for the project and it showed up as a prerequisite.
Oddly enough, I was able to just remove this (and all of the other Microsoft.Windows.Design.* dlls) and it just worked everywhere. I removed them from my project entirely, and everything was fine.
Can someone explain why the VS.NET 2008 project wizard forced these to be included in the project, and more importantly, why ClickOnce thought they needed to be on the client machine to run?
This is just a curiosity question, but I'm sure I'm not the first to be bitten by it. Hopefully, this post will at least save someone else the headache.
Try to remove all references to *.Design.dll. In my case it was WPFToolkit.Design.dll.
This is old and the OP is gone, but I ran into this today, so I thought I'd mention that my solution was removing a reference to one of the WPFToolkit references that ends with .Design.
I had referenced System.Windows.Controls.Input.Toolkit, but also had a reference to System.Windows.Controls.Input.Toolkit.Design, which should not have been there. Removed it, and all was right with the world again.
A way to find out the code that is loading the assembly is explained here:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/755272f6-0e79-4a6d-ae50-4412d0f2bc4c
I found that I was using the SelectionCommands.Clear property which is inside the Microsoft.Windows.Design.Interaction namespace inside the Microsoft.Windows.Design.Extensibility Version dll.
Beats be why this dll isn't included in the .NET 3.5 install.

Running a WPF application on Windows XP

I recently built a new application using WPF, so that I can learn the new technology. Now that I am trying to deploy the application, it appears as if it is running fine on a Vista system, but on a Windows XP SP2 machine with the .Net fx 3.5SP1, it's not able to load the PresentationFramework.dll file.
I did some further investigation into this and discovered that there is a slight build difference between the PresentationFramework.dll files on my xp test machines vs. what is on my Vista development machine.
What I'm curious about is if anyone else has run into this issue as well, and what they did to remedy the situation so that they could develop on Windows Vista, but deploy the developed application to both Vista and XP clients.
Thanks.
I need to add to this a bit... on the vista machine and on the client machine, I've got .Net Fx 3.5 SP1. I had done a bit of digging, and found out that the PresentationFramework.dll file is the same, except the last set of versioning numbers.
Has anyone found a decent work around for this issue?
Sorry that I left this stagnant, but I figured out the issue I was running into. Turned out that there was corruption in the Windows XP box I was using as a test bed.
I was working between stackoverflow and another forum for the package I was writing the Add-in for. When I learned of the answer, this is what I posted, in case I ran into issue in the future.
I thought that I'd post this here, so
that I would have reference, and also
in case anyone else would need
reference to it for the future... I'm
working on another Dinerware Add-on
using WPF, and although it was running
fine on my development machine, every
time I'd go to run it on a test
machine (a machine ghosted like it was
in the field at a customer's
location), I kept getting weird
processing errors.
I did hours of searching online, only
to come up empty handed until I ran
across this article:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6e5de3d8-fc02-4504-b00f-7a2192d24a48/
which gives a link to the download of
the WIC (Windows Imaging Components),
located here:
http://www.microsoft.com/downloads/details.aspx?FamilyID=8e011506-6307-445b-b950-215def45ddd8&displaylang=en
For some reason, what is/was happening
is that the Windows Imaging components
have become corrupt against what my
application is looking for. TO fix
the issue, you have to:
1) navigate to
%windir%\$NtUninstallWIC$\spuninst\
and run the spuninst.exe file in
there. That will remove the Windows
imaging components. 2) after you have
completely removed the components, you
will then re-install them using the
second link from above.
So far, I've not run into any further
issues.
What a crazy thing that
was?!?!?!?!?!?!!
Hopefully, if someone else runs into this issue, I may be able to help them out quick by >putting this out there.
As I said on that forum... hopefully this helps someone else out that runs into this issue in the future.
I've done a bit more experimentation and built a test WPF project and used a Setup and Deployment project instead of a WiX installer. for some reason, the application is working fine when its installed with the Setup and Deployment installer, but when using WiX, it's having issues...
Beginning to think the issue has to do with WiX, and not the .Net Fx version/build
You can have this problem sometimes with templates and Blend, although I thought it had been fixed in the latest Blend. Basically when Blend "pulls in" information for making a new template, it can sometimes copy in Aero only stuff from Vista, which means the control you then create is then reliant on Vista :-(
I did think this was fixed though, although you may have been bitten by it if the project has taken a while to put together.
Make sure that .NET Version on your Vista and XP machine are same.

Resources