0

So I have a c# application that runs perfect on my machine. When I try to run it on a pc without vs 2012 I get this exception at some point. I cant figure out what vs is installing that my application is referring to..

system.io.filenotfoundexception could not load file or assembly system.web.Mvc

I checked the installed drivers / programs but the program still works if I uninstall mvc 3. But if I remove vs it stops working. .net 4.5 is installed on the pc.

The application:

The application connects to a rest api and performs some post / put / get / del requests.

Florian Schaal
  • 2,586
  • 3
  • 39
  • 59
  • 2
    Make sure your pc has [.Net framework 4.5](http://www.microsoft.com/en-ca/download/details.aspx?id=30653) – Habib Sep 16 '13 at 14:41
  • What is your C# application doing? It's very odd that it would need MVC if it's not a web app... – Jon Skeet Sep 16 '13 at 14:41
  • @Habib framework 4.5 is installed. – Florian Schaal Sep 16 '13 at 14:47
  • Key question here, is this winforms app or Web? – T.S. Sep 16 '13 at 14:48
  • @T.S. Its a winforms app – Florian Schaal Sep 16 '13 at 14:48
  • 1
    Then, there is a problem. In winforms you shouldn't call anything from system.web.Mvc. I am not even sure if you can install mvc framework without VS installed because the whole point of it is to install into VS. But you can try to load MVC ddls into your app bin. To call REST you should only need System.Net.Http – T.S. Sep 16 '13 at 14:49
  • Do you see Mvc in the application files list? Go to your `Project` `Properties`, select `Publish` on the left list, click `Applications Files...`. Also check the list obtained by `Prerequisites...`. How did you check if you don't have reference to that file? I advise to check in all csproj (which would uncover static references), and also in your code (to uncover dynamic loads). – Csaba Toth Sep 16 '13 at 15:52
  • @CsabaToth Yes i do! Let me try to include it and see if it works – Florian Schaal Sep 16 '13 at 18:19
  • @FlorianSchaal That (`Application Files...`) is basically the list what `Visual Studio` would package if you create an installer for your project with `Visual Studio`. So `Visual Studio` clearly senses a dependency if it is in the list. What framework do you use exactly for you REST purposes? Maybe that pulls it in. Is it maybe a debug version of a framework or development/RC/beta version? – Csaba Toth Sep 16 '13 at 22:14
  • @FlorianSchaal BTW, MVC is an Model-View-Controller framework for APS.NET (web) apps. There are MVC/MVVM frameworks for WPF and Silverlight though. – Csaba Toth Sep 16 '13 at 22:18
  • @CsabaToth I now create a installable application with publish and it works just fine now. I think a reference that i added depends on it. Thanks for pointing me in the right direction!:D – Florian Schaal Sep 17 '13 at 14:35
  • @FlorianSchaal I formulated an answer. But I give +1 to T.S. – Csaba Toth Sep 17 '13 at 15:24

2 Answers2

2

Basically, the answer is, some code in your app tries to load System.Web.Mvc, which shouldn't be part of Windows Forms application. System.Web.Mvc is installed with VS2012 and is part of the WEB development environment. Uninstalling VS2012 removes that and your app fails. The fix should consist of removing System.Web.Mvc from your Windows Forms application

T.S.
  • 18,195
  • 11
  • 58
  • 78
  • Hhm strange, I cant find any reference to System.Web.Mvc – Florian Schaal Sep 16 '13 at 15:20
  • 2 things possible: 1- Other DLL is referenced, which is dependent on `System.Web.Mvc`; 2 - `System.Web.Mvc` loaded dynamically. Search in code files. In both cases it could be either DLL itself or another one which is dependent on it – T.S. Sep 16 '13 at 15:24
1

You can create an installer very quickly with Visual Studio by going to your Project Properties, select Publish and then launching the Publish Wizard.... If your project really depends on System.Web.Mvc, it'll be included. You can also specify prerequisites throughout the wizard. The created installer can be used on machines which doesn't have Visual Studio or other developer frameworks installed.

The question still remains: what depends on System.Web.Mvc? If we want the answer it needs investigation of your references.

Csaba Toth
  • 10,021
  • 5
  • 75
  • 121