views:

172

answers:

4

I'm not really a C#/.Net developer, but I've been asked to solve an issue we are having. We have a small command line app in C# that has been working and recently ran into trouble. On my machine I can build and run it, but when I try to run it on some of our servers it fails. I looks like it fails on the ones that have .Net 2.0 with service pack 2 installed. I don't have this service pack.

Here's the error that we see:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.File name: 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

As far as I can see the system references are set to Specific Version: False.

+2  A: 

Have you packaged the application into a setup? Using a Setup project will usually ensure you have all the required dependencies installed.

Filmund
There is an option to Copy Local on the references that was set to false for the system assemblies. I wonder if I set that to true will it work and how much bloat it would cause.
Matt Price
It seems if I copy over System.Data.dll, System.dll, System.Xml.dll and System.configuration.dll it will work. But this seems an inelegant hack at best.
Matt Price
+2  A: 

Make sure System aliases set to Global, Copy Local is False and Specific Version is set to False too.

Ray
Yeah, that's how it was set.
Matt Price
Maybe then .NET installation is incorrect on the target system?
Ray
+1  A: 

Do you have access to the target system? The reason being is that this can be caused by an incorrect installation. As far as I can remember, in Add/Remove in WindowsXP & Vista, you can choose to 'repair' the .NET Framework instead of completely uninstalling it.

baeltazor
A: 

Firstly, do you have a config for your application (ie a file named yourappname.exe.config where yourappname obviously is your application name) and is there anything there forcing it to use a particular framework version.

Otherwise you could create one, (something like)

<?xml version ="1.0"?>
<configuration>
    <startup>
        <supportedRuntime version="v2.0.50727"/>
    </startup>
</configuration>

You can have as many supportRunTime lines as required, so you can add your version as well as the end-users version to the app config.

sgmoore