MVC, Compile Error with Compiled App_Code - asp.net

I have some classes in App_Code that are not accessible unless I change them from Content to Compiled. Once I change them to Compiled, I start getting error messages and warnings that aren't making any sense to me.
1:
Severity Code Description Project File Line
Warning CS0436 The type 'Article' in 'C:\Users\Ken\OneDrive\Web site\Choatech\App_Code\Article.cs' conflicts with the imported type 'Article' in 'choatech, Version=2015.7.5693.41559, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\Ken\OneDrive\Web site\Choatech\App_Code\Article.cs'. Choatech C:\Users\Ken\OneDrive\Web site\Choatech\App_Code\SQLProvider.cs 12
2:
Severity Code Description Project File Line
Error CS0433 The type 'SQLProvider' exists in both 'choatech, Version=2015.7.5693.41559, Culture=neutral, PublicKeyToken=null' and '1_App_Code, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' Choatech C:\Users\Ken\OneDrive\Web site\Choatech\Views\Article\Index.cshtml 24
I understand it's trying to tell me that the item exists twice, but it's referencing the same file both times in the first error... Which isn't making sense to me.
In the second error it's listing some error that appears to be in the project file itself...
Changing the classes to Content resolves the errors, but then my code isn't accessible throughout my application.
I am using MVC, if that makes any difference.
Thanks.

Don't put these files in App_Code. Source code kept in the App_Code folder is automatically compiled at runtime, resulting in the CS0436 warnings that you are seeing.

Related

Use EF 6.0 SaveChanges() function causes error "Could not load file or assembly " oracle. manageddataaccessdtc, version=4.122.19.1"

I use Oracle.ManagedDataAccess nuget packet, I publish the project to IIS, everything it ok, but if I call the EF function SaveChanges(), I get this error:
Could not load file or assembly Oracle.ManagedDataAccessDTC, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342 Or one of its dependencies,Find the assembly manifest definition does not match the assembly reference. ( exception from hresult:0x80131040 )
I put the Oracle.ManagedDataAccessDTC.dll in the publish folder in the bin directory, but I still get the error.
Please give me some advice! Thanks!

Alachisoft.NCache.Web.SessionState.NSessionStoreProvider can't find protobuf-net

I've downloaded the open source edition of ncache and i've followed the instructions at http://www.alachisoft.com/resources/docs/ncache/help/aspnet-session-state-provider.html?mw=Mzk2&st=MQ==&sct=MTk4&ms=QwAAEAAAIAAAAQACATgIAhA=
to configure my website to put the session state in ncache.
However, i get this error hitting the site.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'protobuf-net, Version=1.0.0.282, Culture=neutral, PublicKeyToken=257b51d87d2e4d67' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 136:
Line 137:
Source File: C:\inetpub\wwwroot\xxxx\web.config Line: 138
Assembly Load Trace: The following information can be helpful to determine why the assembly 'protobuf-net, Version=1.0.0.282, Culture=neutral, PublicKeyToken=257b51d87d2e4d67' could not be loaded
I'm not sure where to find that dll or why it can't be loaded? I tried using nuget to install protobuf-net but there is no 1.0.0 version and the recent version does not fix the problem when i copy it to the bin folder.
Randy
Turns out the issue was that you need NCache installed on the web servers too, in addition to the cache servers. This is a better page to follow if you are just starting out with NCache for sessionState.
http://www.alachisoft.com/resources/docs/ncache/ncache-session-guide.pdf

The type or namespace name 'ViewPage' does not exist in the namespace 'System.Web.Mvc'

I have a solution (VisualStudi0 2013) that worked perfectly well until couple of days ago. Suddenly after I had restarted my computer I started getting the following error locally everytime I run the debugger. There are no errors in the solution itself but only in the browser. I'm able to clean, build, rebuild and publish the solution without any problems. In fact the solution works well on-line but not locally on my computer.
Another fact is that the aspx files are debugged without any error. It's only the pages that are served with MVC that throws this error.
I searched for the ViewPage and it only exists in the web.config.
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=XXXXXXXXXXXXX"
I'm certain that the ViewPage is available in the solution references under the 'System.Web.Mvc' but why I'm getting this error in a file in the Temporary ASP.NET Files. I cleared the temp files but it didn't help.
Compiler Error Message: CS0234: The type or namespace name 'ViewPage' does not
exist in the namespace 'System.Web.Mvc' (are you missing an assembly reference?)
Source Error:
Line 136: public class views_home_index_aspx : global::System.Web.Mvc.ViewPage, System.Web.SessionState.IRequiresSessionState, System.Web.IHttpHandler {
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\vs\6f597118\63e8eef9\App_Web_index.aspx.a8d08dba.6ujukvge.0.cs Line: 136
That was caused by a Security Update. I fixed it by setting CopyLocal to true on the System.Web.Mvc reference but you can get more details at http://blogs.msdn.com/b/webdev/archive/2014/10/16/microsoft-asp-net-mvc-security-update-broke-my-build.aspx

Type or namespace is not found Error when deploying the website

the website works nice on local system but when I deploy it , an exception throws that :
CS0234: The type or namespace name 'ISisoDatabase' does not exist in the namespace 'SisoDb' (are you missing an assembly reference?) ?
it's a shared host by the way .
any idea why this is happening ?
Edit : I used Web Project instead of WebSite and this error is gone but another exception is thrown :
Could not load file or assembly 'SisoDb, Version=15.1.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The module was expected to contain an assembly manifest.
solved : the problem was the ftp client I used to upload dlls . it sounds ftp corrupted the dlls. when I added assemblies using file manager , the problem was solved
the problem sometimes is the ftp client that is used to deploy files .they corrupt files when uploading them . try uploading files using file manager .

HttpHandlers x64 problem

I developed a .Net 3.5 x64 web application that includes a custom HttpHandler in the config:
<add path="*.class1" verb="GET" type="ClassLibrary1.Class1Handler"/>
This works when the platform target for ClassLibrary1 is set at x86.
However, when I set this to x64 I get the following error when I run web application starts (it compiles just fine):
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Does this mean that a HttpHandler can be compiled at x86 only?
That doesn't make much sense to me.
Does anyone have an idea of what could be going on?
Edit 1:
The ClassLibrary1 project is just an empty class library project with a single HttpHandler added (which is also empty).
Edit 2:
I am also getting these warning messages when compiling, I am pretty sure they have something to do with this problem:
Assembly generation -- Referenced assembly 'mscorlib.dll' targets a different processor HttpTest
Edit 3:
I manually edited the project file to force references to the x64 assemblies, like this:
<Reference Include="$(Windir)\Microsoft.NET\Framework64\v2.0.50727\System.dll"/>
This does supress the above warning message, but the problem isn't resolved.
Thanks!
You probably compiled your assembly ClassLibrary1 with the attribute x86. Try to compile it with AnyCPU tag.
One of your dependent assemblies is compiled with the flag set to x86 rather than AnyCPU or x64
See this page for how to use the coreflags.exe to query the assebly in question

Resources