开发者

Can razor use an object from an exe as opposed to dll for View in ASP.net MVC

I have a project which sends the status of a system via XML to a client. I have another project that is an ASP.Net MVC project. If I use the dll of the first project then I don't have any problems. If I use the exe from the first project then I get the following error:

The type or namespace name 'XXXX' does not exist in the namespace 'YYYYY' (are you missing an assembly reference?)

I think this error is when the page is render. I am not sure how razor works but it seems to create temporary classes.

public class _Page_Views_Status_Index_cshtml : System.Web.Mvc.WebViewPage<xxxx.yyyy.Monitor开发者_开发问答ing.SystemStatus>

Are we not able to reference classes in an exe? I don't see any reason why this shouldn't work.


Probably the class that you are trying to use is located in the DLL and not the EXE, so you need to reference the DLL. You could also reference EXE (assemblies) but in this case make sure that the class that is shown in the error message is actually present in this EXE.

So you could have the following solution structure:

  • SomeProjectLib (Class library containing the YYYYY.XXXX class)
  • SomeProjectWin (An exe which references the class library and uses the class from it)
  • SomeProjectWeb (An ASP.NET MVC project which references the class library and uses the class from it)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜