ASSEMBLY 1
This is my project structure (I serve up content from embedded resources):
Common_Assembly.dll
Css
Common.css
Views
Shared
_Layout.cshtml
This also has a class called Model.cs, which is essentially just:
public class Model
{
public string Title {get; set; }
}
_Layout.cshtml
@model MyNameSpace.Model
<html>
<head>
<script language="javascript" href="css/common.css"></script>
<title>@Model.Title</title>
</head>
<body>
@RenderBody
</body>
</html>
ASSEMBLY 2
I then have a second assembly (which references the one above) and is the one that actually hosts the web-service:
Concrete_Assembly.dll
Views
Index.cshtml
This has a class called IndexResponse
that derives from Model
in the other assembly.
public class IndexResponse : Model
{
}
Index.cshtml
@Model MyOtherNameSpace.IndexResponse
<p>Test</p>
Now, the problem. If I remove the @Model
line, everything works correctly and I see my index page within the layout page of the other DLL (I use a custom VirtualPathProvider to locate resources across multiple Dlls). However, if I try and use the IndexResponse
as a model in the index page, I get a HttpCompileException
. As it is thrown by an external component I do not actually know what the exception message is (I use service stack binaries).
At first I wondered if it was because the model class was different from the layout's class (even though it derives from it). To test that theory I created a TestModel
class that derives from Model
(placed IN the common assembly), and used that - it worked fine.
This leads me to believe it is because the IndexResponse
is in the secondary assembly - but can't be sure because I can't see the error.
Any help would be appreciated!
EDIT
For completeness, here is the actual WebService method. I do not believe anything is wrong here as it worked fine when I did my other tests (using TestModel
instead).
public IndexResponse Any(Index index)
{
return new IndexResponse() { Title = "Test Title" };
} // eo Any
EDIT 2
Apologies for all the edits. Furthermore, is there anyway I can get hold of this exception or handle it so I can have a look at the error? It would be nice to catch this and display it - otherwise developing these pages as embedded resources is going to be like pulling teeth :)
EDIT 3
After following some suggestions from Mythz, and adding the correct namespaces in to the Razornamespaces configuration, I have finally gotten hold over the error that it is throwing:
+ $exception {"(0): error CS1704: An assembly with the same simple name 'Concrete_Assembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null has already been imported. Try removing one of the references or sign them to enable side-by-side."} System.Exception {System.Web.HttpCompileException}
`