ASP.NET Web API – FileNotFoundException: Could not load file or assembly - asp.net

I am using Visual Studio for Mac [Community] Version 8.2.3 on macOS Mojave (10.14.6).
I created a ASP.NET Core API Solution. I need to access a third party DLL and added it to my Project -- it shows up under Dependencies/Assemblies. I am accessing it within a POST method.
Project builds fine. I get the following error when I run in Debug mode and access the POST URL:
$ dotnet run
Using launch settings from /Users/vishal/Projects/Triceratops/Properties/launchSettings.json...
: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/Users/vishal/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
Hosting environment: Development
Content root path: /Users/vishal/Projects/Triceratops
Now listening on: https://localhost:8080
Now listening on: http://localhost:8000
Application started. Press Ctrl+C to shut down.
dbug: HttpsConnectionAdapter[1]
Failed to authenticate HTTPS connection.
System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslState.ThrowIfExceptional()
at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsServerAsync>b__51_1(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.AspNetCore.Server.Kestrel.Https.Internal.HttpsConnectionAdapter.InnerOnConnectionAsync(ConnectionAdapterContext context)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 POST https://localhost:8080/api/battery application/json 10432
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[3]
Route matched with {action = "Post", controller = "Battery"}. Executing controller action with signature Double[,] Post(BatteryParamModel) on controller Triceratops.Controllers.BatteryController (Triceratops).
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
Executing action method Triceratops.Controllers.BatteryController.Post (Triceratops) - Validation state: Valid
info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
Executed action Triceratops.Controllers.BatteryController.Post (Triceratops) in 109.7701ms
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.BadImageFormatException: Could not load file or assembly 'RenewablesLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. An attempt was made to load a program with an incorrect format.
File name: 'RenewablesLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
at Triceratops.Controllers.BatteryController.Post(BatteryParamModel data)
at lambda_method(Closure , Object , Object[] )
at Microsoft.Extensions.Internal.ObjectMethodExecutor.Execute(Object target, Object[] parameters)
at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 285.122ms 500 text/html; charset=utf-8
What am I missing/doing wrong?

Try cleaning the solution and rebuild. Sometimes restarting the Visual Studio also clears this type of issue.
If you are using any package manager like nuget to install, see the packages.config file has the assembly added or add the dependent assembly file in config. See the build files in bin has this dll or not.

An attempt was made to load a program with an incorrect format.
User error. Mine.
I should have been using the x64 DLL and was using the x86 DLL instead. That appears to have fixed it.

I have the same error, I wrote in the package manager console dotnet restore and it works for me!

Related

Sitefinity starts upgrade after deploying to production server

We're in the process of moving our existing Sitefinity 10.x site to a new hosting provider, but running into a series of issues.
First, we backed up and restore the site from the current host to our local dev environment and got it up and running within about 10 minutes - no issues.
We again backed up everything up and then deployed to the new hosting provider in a shared hosting environment following these instructions: https://www.progress.com/documentation/sitefinity-cms/deploy-projects-to-shared-hosting
The result is that Sitefinity somehow seems to think that it needs to install/upgrade and ends up in a loop of Exceptions being thrown creating really large files in the Logs directory in App_Data including Error and UpgradeTrace log files of sizes between 6 and 20Mb.
What am I missing here? This is normally fairly easy to do.
Here's a small sample of what the System Initialization process is outputting.
HandlingInstanceID: a7548528-e50b-4c45-ac31-14997da528e2 An exception of type 'System.Exception' occurred and was caught.
----------------------------------------------------------------
11/05/2020 08:30:45 Type : System.Exception, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Message :
FAILED : SiteInitializer : Upgrade to 1106 (Upgrade backend pages accessible to all in Backend role) -
Exception has been thrown by the target of an invocation.
Source :
Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : HResult : -2146233088 Stack Trace : The stack trace is unavailable.
Additional Info:
MachineName : --hidden-- TimeStamp : 2020/11/05 6:30:45 AM
FullName : Telerik.Sitefinity.Utilities, Version=10.0.6400.0, Culture=neutral, PublicKeyToken=b28c218413bdf563
AppDomainName : /LM/W3SVC/556/ROOT-1-132490314385720168
ThreadIdentity : Anonymous WindowsIdentity : --hidden\hidden--
Requested URL : http://127.0.0.1/
Inner Exception ---------------
Type : System.Reflection.TargetInvocationException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message : Exception has been thrown by the target of an invocation.
Source : mscorlib Help link :
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Object InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
HResult : -2146232828
Stack Trace :
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Telerik.Sitefinity.Abstractions.UpgradeMethod.Execute(Object upgradeContext)
at Telerik.Sitefinity.Abstractions.SiteInitializer.Upgrade[TUpgradeInfoAttribute](Object instance, Int32 upgradeFrom, Object upgradeContext)
Inner Exception --------------- Type :
Telerik.Sitefinity.SitefinityExceptions.ItemNotFoundException, Telerik.Sitefinity, Version=10.0.6400.0, Culture=neutral, PublicKeyToken=b28c218413bdf563 Message :
You are trying to access item that no longer exists. The most probable reason is that it has been deleted by another user.
Source : Unity_ILEmit_DynamicClasses Help link : Data : System.Collections.ListDictionaryInternal
TargetSite : Telerik.Sitefinity.Pages.Model.PageNode GetPageNode(System.Guid) HResult : -2146233088 Stack Trace :
at DynamicModule.ns.Wrapped_OpenAccessPageProvider_325400689b95401abccc69f6d0957c5f.GetPageNode(Guid id)
at Telerik.Sitefinity.Modules.Pages.PageManager.GetPageNode(Guid id)
at Telerik.Sitefinity.Abstractions.SiteInitializer.UpgradeTo1106()
Expand 08:57:24
FAILED : SiteInitializer : Upgrade to 1106 (Upgrade backend pages accessible to all in Backend role) - Exception has been thrown by the target of an invocation.
08:57:24
Upgrading Progress Sitefinity CMS from build version 1 to 6400.
08:57:24
System is initializing...
08:57:24
Actually it turns out to have been rather simple.
I added <clear /> to the data config file to remove the
machine.config's configuration for DB's. This is where I realised
something was going wrong with the DB restore.
Using SolidCP on the hosting providers site I thought the DB restore
was successful, but it turns out it was silently failing.
The ISP did a manual restore which was successful
Finally we added <clear /> to the SiteMapProvider setup because the ISP also has MySql providers installed which causes issues with Sitefinity if you don't clear the machine.config's configuration for SiteMaps.
After that everything worked as expected.

VS2015/DNX building Microsoft.Framework.Logging from github results in testing error

So I have my VS2015 Enterprise installed. I grab the latest Microsoft.Framework.Logging from github, load the solution and build it.
After it restores all the dependent packages it does seem to build OK but then I get this error on the test:
Starting Microsoft.Framework.TestHost [C:\Users\dan_000\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnx.exe --appbase "D:\code\DanForks\Logging\test\Microsoft.Framework.Logging.Test" Microsoft.Framework.ApplicationHost --port 1388 Microsoft.Framework.TestHost --port 5651]
System.InvalidOperationException: Unable to load application or execute command 'Microsoft.Framework.TestHost'. Available commands: run, test.
at Microsoft.Framework.ApplicationHost.Program.ThrowEntryPointNotfoundException(DefaultHost host, String applicationName, Exception innerException)
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at dnx.host.Bootstrapper.RunAsync(List``1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
When I run the same command in a command prompt with DNX_TRACE=1, I get:
Test" Microsoft.Framework.ApplicationHost --port 1388 test --port 1462
The servicing index file at: C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt does not exist or could not be opened.
Loaded module: dnx.clr.dll
Found export: CallApplicationMain
Information: [DomainManager] Using Desktop CLR v4.5.1
Information: [Bootstrapper] Runtime Framework: DNX,Version=v4.5.1
Information: [DefaultHost]: Project path: D:\code\DanForks\Logging\test\Microsoft.Framework.Logging.Test
Information: [DefaultHost]: Project root: D:\code\DanForks\Logging
Information: [DefaultHost]: Packages path: C:\Users\dan_000\.dnx\packages
Information: [DependencyWalker]: Walking dependency graph for 'Microsoft.Framework.Logging.Test DNX,Version=v4.5.1'.
Information: [WalkContext]: Graph walk stage 1 took in 28ms
Information: [DependencyWalker]: Graph walk took 31ms.
Information: [ServicingIndex]: Servicing index not found at C:\Program Files (x86)\Microsoft DNX\Servicing\index.txt
Information: [WalkContext]: Populate took 15ms
Information: [DependencyWalker]: Resolved dependencies for Microsoft.Framework.Logging.Test in 49ms
Information: [LoaderContainer]: Load name=xunit.runner.aspnet
Information: [NuGetAssemblyLoader]: Loaded name=xunit.runner.aspnet in 5ms
Information: [LoaderContainer]: Load name=xunit.runner.utility.AspNet, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null
Information: [NuGetAssemblyLoader]: Loaded name=xunit.runner.utility.AspNet, Version=99.99.99.0, Culture=neutral, PublicKeyToken=null in 1ms
Information: [LoaderContainer]: Load name=xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c
Information: [NuGetAssemblyLoader]: Loaded name=xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c in 1ms
Information: [LoaderContainer]: Load name=Microsoft.Dnx.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
Information: [NuGetAssemblyLoader]: Loaded name=Microsoft.Dnx.Runtime.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null in 1ms
System.NullReferenceException: Object reference not set to an instance of an object.
at Xunit.Runner.AspNet.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at dnx.host.Bootstrapper.RunAsync(List``1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
My solution DNX versions for all the projects is 1.0.0-beta6.
I'm not extremely familiar with how the xunit stuff all works. I figure I have some sort of runtime mismatch somewhere?
I think one of the dependency changes which breaks xunit runner. I think you have to wait xunit update reference or code to address the changes. Also, different version of xunit target different dnx as well. Make sure update xunit to xUnit.net 2.1 Beta 4
http://xunit.github.io/docs/getting-started-dnx.html

Microsoft Enterprise Caching Block + ASP.NET dev server shows a strange reference not found error

I'm working on an ASP.NET project and I've started getting this really strange error when I view a page from Visual studio.
The web reference it is looking for is some random string, so I'm assuming it's in the Temporary ASP.Net file folder.
The exact error is:
Unable to find assembly 'App_WebReferences.uphmdpcs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.Serialization.SerializationException: Unable to find assembly 'App_WebReferences.uphmdpcs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
Source Error:
Line 59: public static object GetD(string key)
Line 60: {
Line 61: CacheManager cache = CacheFactory.GetCacheManager("Cache Manager");
Line 62: return cache.GetData(key);
Line 63: }
Here's part of the stack trace:
SerializationException: Unable to find assembly 'App_WebReferences.uphmdpcs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.]
System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly() +1656829
System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name) +1641477
System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable) +120
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record) +400
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum) +62
System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run() +144
System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +183
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage) +190
Microsoft.Practices.EnterpriseLibrary.Caching.SerializationUtility.ToObject(Byte[] serializedObject) +97
I'm using Enterprise Library 2007, .Net 2 , VS 2005 (i've tried 2008 too), Windows Server 2003.
I've tried giving generous permissions on the Temporary ASP.NET folder to 'Everyone' as a last resort, but that didn't help.
Has anyone had an error like this before? I'm stumped.
I don't know for sure why this is happening, but I found out it's related to the IsolatedStorage being used by the Caching block. It may be that the storage isn't cleaned up since our application is exited uncleanly.
The temporary fix is to delete the IsolatedStorage for the application. The location is:
c:\Documents and Settings\YOURUSERNAME\Local Settings\Application Data\IsolatedStorage\
I removed the directories in that path and that cleared up the issue. I've had to do this everytime the run fails, which is often since I'm in development.
Yes, the error doesn't seem related to the cache since it's complaining about not finding an assembly, but it works.

Couldn't load File or Assembly

I have a web application in .Net in which I use Ajax controls in some pages. Those pages are working in localhost, but when hosted, the pages in which Ajax included shows following error.
Server Error in '/Allforkids' 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.FileIOPermission, mscorlib, Version=2.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.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessPermission.Demand() +58
System.Reflection.Assembly.VerifyCodeBaseDiscovery(String codeBase) +118
System.Reflection.Assembly.get_CodeBase() +35
System.Web.Handlers.ScriptResourceHandler.GetCodeBaseWithAssert(Assembly assembly) +31
System.Web.Handlers.ScriptResourceHandler.GetLastWriteTime(Assembly assembly) +36
System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfoInternal(Assembly assembly) +61
System.Web.Handlers.ScriptResourceHandler.GetAssemblyInfo(Assembly assembly) +62
System.Web.Handlers.RuntimeScriptResourceHandler.System.Web.Handlers.IScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +325
System.Web.Handlers.ScriptResourceHandler.GetScriptResourceUrl(Assembly assembly, String resourceName, CultureInfo culture, Boolean zip, Boolean notifyScriptLoaded) +33
System.Web.UI.ScriptManager.GetScriptResourceUrl(String resourceName, Assembly assembly) +89
System.Web.UI.ScriptRegistrationManager.RegisterClientScriptResource(Control control, Type type, String resourceName) +111
System.Web.UI.ScriptManager.RegisterClientScriptResource(Control control, Type type, String resourceName) +9
Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
Can anybody give appropriate solution to get rid of this error?
This looks like something you need to bring up with your hosting provider. It would appear from the error that a configuration setting in the hosting server prohibits access to local files.
You could try adding this to your web.config:
<system.web>
...
<trust level="Medium" originUrl="" />
...
</system.web>
But, if the hosting provider has a setting in the machine.config that supersedes this, it will not make a difference. Here more information on that.
It could be security permissions on your folder/files. Are you writing to any files (like an Access DB)? Make sure your ASP.Net machine account (such as PCName\ASPNET) on the server has access to the folder.
Here is the code from the Assembly class:
private void VerifyCodeBaseDiscovery(String codeBase)
{
if ((codeBase != null) &&
(String.Compare( codeBase, 0, s_localFilePrefix, 0, 5, true, CultureInfo.InvariantCulture) == 0)) {
System.Security.Util.URLString urlString = new System.Security.Util.URLString( codeBase );
new FileIOPermission( FileIOPermissionAccess.PathDiscovery, urlString.GetFileName() ).Demand();
}
}
The exception is thrown on the .Demand() method asking for FileIOPermissionAccess.PathDiscovery to the file containing the script.
My guess is the IIS worker process does not have READ/BROWSE access to the path containing the script.
If you are registering your own scripts to the ScriptManager, check the filepath (usual rule of thumb, the scripts should not be in a parent (eg. ..\Scripts) folder).
If this exception trows on the AJAX Extensions script resources there might be a problem with the installation of the AJAX Extensions.You need to ask your hosting provider to check it.
PS. Is there more to the stack trace? It seems odd that the first call in the stack is "RegisterClientScriptResource".

SecurityException: Request for the permission of type AspNetHostingPermission failed

Setting up a new developing workstation, when I run the ASP.NET (MVC) application from Visual Studio 2008 I get a SecurityException. Any ideas what might be the problem?
I am accessing the data files over SMB (it's a shared mounted as Z:) and I've given full trust to it by running
caspol -m -ag 1 -url "\\server\share\" FullTrust -exclusive on
The full traceback is:
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.Web.AspNetHostingPermission,
System, Version=2.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.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean
ignoreCase) +0
System.Reflection.Assembly.GetType(String name, Boolean throwOnError, Boolean
ignoreCase) +42
System.Web.UI.Util.GetTypeFromAssemblies(ICollection
assemblies, String typeName, Boolean ignoreCase) +145
System.Web.UI.TemplateParser.GetType(String
typeName, Boolean ignoreCase, Boolean throwOnError) +73
System.Web.UI.TemplateParser.ProcessInheritsAttribute(String
baseTypeName, String codeFileBaseTypeName, String src,
Assembly assembly) +111
System.Web.UI.TemplateParser.PostProcessMainDirectiveAttributes(IDictionary
parseData) +279
Version Information: Microsoft .NET
Framework Version:2.0.50727.4927;
ASP.NET Version:2.0.50727.4927
Are you using a virtual directory that points to a remote share?
http://support.microsoft.com/?id=320268
Also take a look at "Troubleshooting common permissions and security-related issues in ASP.NET"
http://support.microsoft.com/?id=910449
Here's a command which worked for me:
C:\Windows\System32>C:\Windows\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "http://localhost/*" FullTrust

Resources