Does Microsoft.ServiceModel.Web only work in the GAC? - c#

I created my first WCF RESTful service with just one GetData, and it works perfectly in localhost, but when I add it to a hosting environment, I get:
Server Error in '/' Application.
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'ServiceModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Does this mean that I need to place the DLL file in the GAC to this work? Shouldn't it work in the BIN folder of my service?
Here is how my service folder looks like:
Service.svc
Service.svc.cs
web.config
BIN
Microsoft.ServiceModel.Web.dll
Microsoft.ServiceModel.Web.pdb
MyService.dll
MyService.pdb
PROPERTIES
AssemblyInfo.cs
What can I do in order to make this work?

I had the same problem when I first tried to create a virtual directory directly in IIS 7.5, prior to publishing my RESTful web service to this folder.
The solution for me was to use Visual Studio 2008 (Project Properties / Web tab / "Use IIS Server") to choose the folder, and then the "Create Virtual Directory" button on the same tab to create the virtual directory. Everything then worked OK.

Related

404 error for files from new project

I have a solution with several projects. One of the projects is startUp. It references to other projects are registered in the reference. I added a new project Adkplatform.mrp.web (right click to add a new project in visual studio).
I want to display a test page in the browser.
For the test.aspx page I get the error:
Server error in the application '/'. We could not find this resource. Description: http 404. probably, the resource (or one of its dependencies) is deleted, received a different name or temporarily unavailable. Review the following url and verify that it is entered correctly.
For the test.html page I get the error:*
*Detailed Error Information:
Module IIS Web Core
Notification MapRequestHandler
Handler StaticFile
Error Code 0x80070002
Requested URL http://localhost:3333/test.html
Physical Path D:\WORK\Projects\Test\Software\.Net\Test\test.html
Logon Method Cookies*
I understand it, the search for files in the startUp project.
The test files have Build Action: Embedded Resource
What did I forget to do? In advance, thank.
Sorry, the problem is in our local snippet. It is necessary for the display to call a method c# HostingEnvironment.RegisterVirtualPathProvider for each assembly. For a new project (and new assembly), it not was done.

Add .cs file to ASP Web Site project

I am working on an ASP.NET website and as part of the website I created a file called Global.cs which is used to hold all my helper classes. However, unfortunately, I am constantly getting errors saying there has been a problem while compiling this file. All the classes inside the file are included in single namespace - "Global".
When using it 'inline' eg. Global.SomeStaticClass.Method() :
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Global' does not exist in the current context
When using "using Global;" directive:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Global' could not be found (are you missing a using directive or an assembly reference?)
As suggested in many posts, I tried including the class in App_Code folder of my project and the namespace, "Global", is detected by the Visual Studio (no errors when adding "using Global;" directive, or when using it inline "Global.Class.Method()". However, it still fails whenever I try to access the page in the browser.
I could not find a simple solution to my problem and decided that the easiest and the most time efficient solution will be to convert my Website project to a Web Application project. You can read how to convert your Website to a Web Application at: https://blogs.msdn.microsoft.com/webdev/2009/10/29/converting-a-web-site-project-to-a-web-application-project/
With the project converted to a Web App I was able to attach my class files after compiling them to a DLL library, as it did not accept any uncompiled files inside App_Code folder by throwing an exception.
The directory '/website/App_Code/' is not allowed because the application is precompiled.
If you encounter the same issue, you can learn how to compile C# files using Developer Command Prompt here: https://msdn.microsoft.com/en-us/library/78f4aasd.aspx

App_code codefiles unaccessable when "web site" is published

When I test my web site (asp.net c# .net4) on the localhost, everything works fine.
However, when I publish it to my webserver, I get the error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'MyWhateverNamedHere' could not be found (are you missing a using directive or an assembly reference?)
My code file (MyWhateverNamedHere.cs) lives in my App_Code folder, which IS moved to the webserver.
I have read where people move codefiles out of the App_Code folder. Didn't work for me. I tried giving them namespaces, and static references and just about everything I can think of. Then I found a solution that said Build Phases > Compile. But that's not an option for "web sites".
Any help?

Cannot find classes once ASP.NET website is hosted

My project is an ASP.Net website that connects to an SQL database.
It compiles fine locally in Visual Studio, but once it is hosted (myWindowsHosting.com) it throws this error:
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'IDefaultView' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 9: namespace HFDB2
Line 10: {
Line 11: public partial class Default : System.Web.UI.Page, IDefaultView
Line 12: {
Line 13: public event EventHandler btnNextClicked;
In this example I am trying to implement an Interface to the Default webform. But a similar error occurs for any class I try to reference.
Why cant my project find any classes once it is hosted?
Does it have anything to do with my folder structure?
My classes are not in an App_Code folder because apparently you dont need one for websites. I tried putting them in an App_Code folder anyway, but it gave a different error.
Note that I uploaded everything you see inside my project folder to the host.
I was deploying my application incorrectly. As Ben Robinson's comment says:
Never deploy source code. The easiest way of creating your collection of files to deploy is to use the Publish option in visual studio.

Why can't the type or namespace be found on IIS 7 server when it works fine on the local machine?

I am using DynamicPDF creator, Visual Studio 2010, and IIS 7.
On my local machine, the line "using ceTe.DynamicPDF;" and subsequent lines work fine, but
when I try to load the page on my server, I get the following error:
"Compiler Error Message: CS0246: The type or namespace name 'ceTe' could not be found (are you missing a using directive or an assembly reference?)"
I have added the .dll file as a reference, and intellisense even works.
I am wondering if it is a problem with assemblies. Any ideas about what I should do to get this working on my server?
May be you lost some of dlls, you can check dll which contains ceTe. ... by dependency walker.

Categories