0

My asp.net site coded in C# is running fine on my local system but when I uploaded the files on the httpdocs folder through plesk I am getting the following error:

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: CS0246: The type or namespace name 'Xyz' could not be found (are you missing a using directive or an assembly reference?)

Source Error:


Line 1:  <%@ Application Language="C#" %>
Line 2:  <%@ Import Namespace="xyz" %>
Line 3:  <%@ Import Namespace="System.Web.Optimization" %>
Line 4:  <%@ Import Namespace="System.Web.Routing" %>

Source File: g:\PleskVhosts\xyz.com\httpdocs\Xyz\Global.asax    Line: 2 

Show Detailed Compiler Output:


C:\Windows\SysWOW64\inetsrv> "C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe" /t:library /utf8output /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Web\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Deployment\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Deployment.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Services\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.EnterpriseServices\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.WorkflowServices\v4.0_4.0.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Web\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.DynamicData\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.DynamicData.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.Activities.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.ApplicationServices\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.ApplicationServices.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.IdentityModel\v4.0_4.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activation\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activation.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" /R:"C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel.Activities\v4.0_4.0.0.0__31bf3856ad364e35\System.ServiceModel.Activities.dll" /out:"C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ba70df64\8ad7fdd9\App_global.asax.8gpjfmvi.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699;1701;612;618 /warnaserror-  "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ba70df64\8ad7fdd9\App_global.asax.8gpjfmvi.0.cs" "C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ba70df64\8ad7fdd9\App_global.asax.8gpjfmvi.1.cs"


Microsoft (R) Visual C# Compiler version 4.0.30319.17929

for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

g:\PleskVhosts\xyz.com\httpdocs\Xyz\Global.asax(2,11): error CS0246: The type or namespace name 'Xyz' could not be found (are you missing a using directive or an assembly reference?)
g:\PleskVhosts\xyz.com\httpdocs\Xyz\Global.asax(3,22): error CS0234: The type or namespace name 'Optimization' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
g:\PleskVhosts\xyz.com\httpdocs\Xyz\Web.config(24,21): error CS0234: The type or namespace name 'AspNet' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)


________________________________________
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18056

Any help would be great.

## New error

****Server Error in '/' Application.

Security Exception

Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 


[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Delegate.DelegateConstruct(Object target, IntPtr slot) +0
   Owin.Loader.DefaultLoader..ctor(Func`3 next, Func`2 activator, IEnumerable`1 referencedAssemblies) +69
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +65
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
   System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +418
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18056****
gunr2171
  • 16,104
  • 25
  • 61
  • 88
Abhishek Ray
  • 33
  • 2
  • 6
  • 6
    Nothing bad about GoDaddy - "Works On My Machine" is a known issue of prgorammers not thinking about what is needed. So, what is the namespace Xyz containing? YOu reference it, so - it has to be there. – TomTom Mar 10 '14 at 14:01
  • Did you upload ALL the files and folders? – Alexander Mar 10 '14 at 14:14
  • when i created the project in the all files were kept in C:\User\Mydocuments\VisualStudio2013\Websites\xyz\. – Abhishek Ray Mar 10 '14 at 14:36
  • I added all files and folders except for the solution file in the Projects folder. – Abhishek Ray Mar 10 '14 at 14:37
  • 2
    I'm voting to close this question as off-topic because this should be directed to Godaddy Customer Support – Adam Aug 22 '16 at 03:34

5 Answers5

5

Had the same problem, the error can be fixed using the web.config. Add the level="Full" level into trust element, like so:

<system.web>
   ...
   <trust level="Full" />
   ...
</system.web>
THBBFT
  • 1,161
  • 1
  • 13
  • 29
4

You need to right click on your Project, and then select "Publish". You can either publish to the file system so you can alter your Web.config before you upload it to godaddy, or you could just set it to publish to the godaddy site. I'd choose the file system approach. One step at a time.

As you said in your comments, "I added all files and folders except for the solution file in the Projects folder", that doesn't do anything. To execute from that, it needs to run from within the Visual Studio IDE. To properly set up where all of the files are supposed to be for production use, you must Publish your web project.

krillgar
  • 12,596
  • 6
  • 50
  • 86
  • Hi,Thanks a lot, I did that but I got an error which seems to me there has to be some changes made to the web.config file. Also i changed settings to ASP.net version 4 (my site is built in .net 4.5) since 4.5 unavailable, changed language to C3 (my coding was in C#) authentication set to none and custom errors set to off. the error is thsi – Abhishek Ray Mar 11 '14 at 12:01
  • the error is the one added to the original post today (after new error line)Thanks a lot for helping me out – Abhishek Ray Mar 11 '14 at 12:08
  • I'm not sure what that exception that was thrown is in reference to. Perhaps trying to connect to your data storage, perhaps not. However, since this is an error unrelated to your original issue of just copying the project file structure instead of publishing, this new error message should really be its own question. Before you post it though, I would try to add some Exception catching to see if you can find where it's occurring so people have a better chance of helping you. – krillgar Mar 11 '14 at 12:17
2

The new error you posted is definitely security related. Go to the websites & domains tab. Under the primary domain for your account click the icon "ASP.NET Settings". When the page loads, you should be able to up the permission to full under "Code Access Security". Give that a shot, let us know if that works

Brian Clifton
  • 691
  • 7
  • 14
1

In addition to the previous comments, one thing I have noticed about GoDaddy with both MVC and WebForms apps is that GoDaddy hates Roslyn. This is the default compiler with new apps from Visual Studio. In addition to setting your CAS to Full access make sure you remove the Microsoft.Net.Compilers package and its dependency from your project, delete all existing files prior to publish (using the checkbox in the publish settings -- don't actually delete everything from your account!) and you should be good to go. I have this problem every time with GoDaddy publishing an app from Visual Studio.

Good luck to anyone who finds this!

moyeradon
  • 443
  • 5
  • 13
0

To solve the security/permission issues with GoDaddy, login to your GoDaddy Windows Plesk account and expand the "Web Hosting" tab. Then, click the "Launch" button to visit the "Websites & Domains" control panel. From there find the website, domain or subdomain you're currently working on. Click the "ASP.NET Settings" button to adjust the "CAS Trust Level" to "Full" and the "Default Webpage Language" to "C#". There you can also enter and save your Connection Strings, Authentication Mode (usually Forms), ASP.NET version, etc..

Synther
  • 32
  • 5