views:

430

answers:

2

Recently I made the WPF application and want to publish it for many users but application seems to have problems on some target user machines. It simply crashes when user is starting it. I build app with .NET Framework v.3.0 as target version and user machine has .NET Framework installed. I just want a way to ensure (for instance with installing system) my application will run with no errors.

What is really strange, on my testing PCs (with no Visual Studio installed but just with 3.0 .NET Framework) it runs perfectly.

Application haven't any addition references except .NET ones.

Here are a link to download this application so if you want you can test it: http://nippon.is74.ru/ForismaticTray.7z

+2  A: 

Use an installer like NSIS and check for your framework. If its not on the target machine, install it.Here's what I do in NSIS

Function IsDotNetInstalledAdv
  !insertmacro MUI_HEADER_TEXT "Checking for prerequisites." "Checking for .net framework 3.5 SP1.."

  ReadRegDWORD $0 HKLM "software\Microsoft\NET Framework Setup\NDP\v3.5" "SP"
  StrCmp $0 1 skip.DotNet  
  !insertmacro MUI_HEADER_TEXT "Installing .net framework." "Installing .net framework 3.5 SP1.."

  DetailPrint "Proceeding to install dotnet bootstrap installer...."
  sleep 1000
MessageBox MB_YESNO|MB_ICONQUESTION "This software requires DotNet framework ${MIN_FRA_MAJOR}.${MIN_FRA_MINOR}.${MIN_FRA_BUILD}.$\r$\n$\r$\nDo you wish to install it now?" IDNO skip.DotNet
  SetOutPath $TEMP
  File "${PACKAGE_DIR_BIN}\dotNetFx35setup.exe"
  GetDlgItem $0 $HWNDPARENT 1
  System::Call "kernel32::CreateMutexA(i 0, i 0, t 'DotNetInstall') i .r0 ?e"
  HideWindow
  ExecWait "$TEMP\dotNetFx35setup.exe /qbf /norestart" $1
  Delete "$TEMP\dotNetFx35setup.exe"
  ShowWindow $0 ${SW_SHOW}
  BringToFront

  IntCmp $1 0 skip.DotNet
  IntCmp $1 8192 skip.DotNet
  IntCmp $1 3010 0 DotNetInstallationFailed DotNetInstallationFailed
  SetRebootFlag true
  goto skip.DotNet

  DotNetInstallationFailed:
    HideWindow
    MessageBox MB_OK|MB_ICONSTOP "DotNet Framework 3.5 was not successfully installed on the machine"
    Quit

  skip.DotNet:
FunctionEnD

Download and package 3.5 SP1 from Micorsoft

More about NSIS

Update: For 3.0 check registry for HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.0 folder.

Cherian
+1  A: 

Could this be a .NET service pack issue? If you are using Visual Studio 2008 to write your application, even if you explicitly set it to target .NET 3.0, your app will basically be targeting .NET 3.0 SP1, since that is installed by .NET 3.5 (which is installed by Visual Studio 2008). You might try upgrading the user's machine to .NET 3.0 SP1 (which is available as a separate download on Microsoft's site, I believe) and see if that fixes the issue.

Andy