Sitefinity starts upgrade after deploying to production server - web-deployment

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.

Related

Unhandled exception in Service Fabric reliable service when PublishSingleFile is set to True

Here's a weird one that has me stumped. I have a .NET Core application I deploy to a Service Fabric Cluster as a Reliable Service. This worked great, until I added the last two lines to the CSPROJ file:
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile> <-- New
<PublishTrimmed>true</PublishTrimmed> <-- New
This bundles up my program into a single EXE. However, when I deploy it, SF tells me that the Application has stopped with an exit code of 3762504530, which basically means some unhandled exception. However, I can go into the node and go to D:\SvcFab_App\ and see the EXE and run it directly from the command line, and it starts up fine.
I then dug a bit through the Windows Event Log, and I see this error come up:
Application: DeviceSync.exe
CoreCLR Version: 4.700.20.26901
.NET Core Version: 3.1.6
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
at System.Reflection.RuntimeAssembly.GetType(QCallAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type, ObjectHandleOnStack keepAlive, ObjectHandleOnStack assemblyLoadContext)
at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at System.Reflection.Assembly.GetType(String name, Boolean throwOnError)
at System.StartupHookProvider.CallStartupHook(StartupHookNameOrPath startupHook)
at System.StartupHookProvider.ProcessStartupHooks()
I reverted my changes to the CSPROJ file and published again, it now it works great again.
My Question: When I use PublishSingleFile, why can I run my program just fine from the command line, but Service Fabric throws an exception when running the same app on the same VM?
Remove the <PublishTrimmed>true</PublishTrimmed>. That is still experimental and might trim some valid dependency from standalone package. The reason it works when you run by logging into the node is that time it's outside the SF runtime and probably able to figure out from global.
Keep only the <PublishSingleFile>true</PublishSingleFile>.
If it still does not work, try to add nuget package reference of netstandard in your main host .csproj <PackageReference Include="NETStandard.Library" Version="2.0.3" />

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

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!

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.

SqlClientPermission failure in assembly loaded via reflection

I am having a really tough time with a problem. I have a web application that I have just modified that allows customers to supply custom assemblies that they can use to hook into an entity save pipeline. These custom assemblies are loaded via reflection when an entity is persisted to the database. They refer to a common DAL assembly that handles all of the data access.
I have a test server (Win2k3) where this system works flawlessly. Now that I've pushed it out to my production server cluster (one Win2k3 and one Win2k8), my custom assembly bombs the first time it calls a DAL method that accesses the database (SQL2005). The log information that I gather indicates that there is a failure in getting a SqlClientPermission. Contrary to best practices, I have my web app running in Full Trust. My custom assembly is strong named.
Are there any suggestions to where I can look for differences between my test server config and my production server configs? If this is not the proper forum, which one is?
Thanks,
Matthew
I was running into a similar issue without the reflection. I was moving a compiled project from my Win 2k3 machine to Win 2k8.
- In IIS go under the bin folder where you dll's are to and right click.
- Go to "Edit Permissions...".
- At the very bottom of the "General" tab there may be a button saying UnBlock.
Win 2k8 doesn't seem to like the dll's copied from another environment.
Not an answer, but more info than I can put in a comment...
It would appear now that this is a Win2k8 vs Win2k3 issue since I no longer get any exceptions in the logs from the Win2k3 server in our cluster.
Basically, what happens is that our entity save pipeline checks to see if the entity type being saved implements a certain interface. If so, then the application goes out to the database to retrieve the assembly and class name of the class that implements the customer-specific pre- and post- save functionality. Those assemblies are under the "App_Data" folder in an folder called "Assemblies\". The application then loads the assembly; uses reflection to instantiate the proper class from that assembly as an interface, then calls the pre and post save methods on that interface to perform the customer specific actions for that particular entity type. In our case, this custom action performs some database operations using our DAL (which uses LLBLGen, FWIW) entity classes.
My initial issue was that I was getting a SecurityException about not allowing partially trusted callers, so I decorated the assemblies that are used with the "AllowPartiallyTrustedCallers" attribute.
In my extension assemby that gets loaded, I instantiate a SqlClientPermission and "Assert()" it, but I haven't anywhere actually granted that permission (except that my web app runs in FullTrust).
Thanks for whatever help you can offer...
-Matthew
Here is the .ToString() output of the exception that gets thrown:
Error performing post-save operation on entity 373c595e-843b-45a1-82d0-aa166daf75de of type SS2DAL.EntityClasses.SurveyResponseEntity: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException: An exception was caught during the execution of a retrieval query: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception. ---> System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
at System.Security.CodeAccessPermission.Demand()
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
The action that failed was:
Demand
The type of the first permission that failed was:
System.Data.SqlClient.SqlClientPermission
The first permission that failed was:
<IPermission
version="1"
AllowBlankPassword="False">
<add KeyRestrictions=""
KeyRestrictionBehavior="AllowOnly"/>
</IPermission>
The demand was for:
<IPermission
version="1"
AllowBlankPassword="False">
<add KeyRestrictions=""
KeyRestrictionBehavior="AllowOnly"/>
</IPermission>
The granted set of the failing assembly was:
<PermissionSet
version="1">
<IPermission
version="1"
Access="Open"/>
<IPermission
version="1"
Allowed="ApplicationIsolationByUser"
UserQuota="512000"/>
<IPermission
version="1"
Flags="Execution"/>
<IPermission
version="1"
Window="SafeTopLevelWindows"
Clipboard="OwnClipboard"/>
<IPermission
version="1"
PublicKeyBlob="0024000004800000940000000602000000240000525341310004000001000100B55C03865E07BCB230B04EF7D9ACF1E7BF41C618DB1327895C25328446039F51CF237A50989E542D3FA9BB5991D303388C5AAC7AE4E071CD7B42B96B16256FF905EC610107DB2A0872E971253919BA528187489FC89FD083118F562319BF3B66CB79035EC50D2291561D4F2B9733AD5E0ECD9BFF9B80B94C40F5888D4E1C5BDD"
Name="ProjectHelpers.Extensions"
AssemblyVersion="2.2009.208.1821"/>
<IPermission
version="1"
Url="file://dc01.bizspeed.datacenter/websites/sitesupervisor files/prjh/ProjectHelpers.Extensions.dll"/>
<IPermission
version="1"
Zone="Internet"/>
<IPermission
version="1"
Level="SafePrinting"/>
</PermissionSet>
The assembly or AppDomain that failed was:
ProjectHelpers.Extensions, Version=2.2009.208.1821, Culture=neutral, PublicKeyToken=4405fd38c7d52787
The method that caused the failure was:
SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 AfterSave(SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2, SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase)
The Zone of the assembly that failed was:
Internet
The Url of the assembly that failed was:
file://dc01.bizspeed.datacenter/websites/sitesupervisor files/prjh/ProjectHelpers.Extensions.dll
--- End of inner exception stack trace ---
at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteSingleRowRetrievalQuery(IRetrievalQuery queryToExecute, IEntityFields2 fieldsToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntityFields2 fieldsToFetch, IFieldPersistenceInfo[] persistenceInfos, IRelationPredicateBucket filter)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntityUsingFilter(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, IRelationPredicateBucket filter, ExcludeIncludeFieldsList excludedIncludedFields)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchEntity(IEntity2 entityToFetch, IPrefetchPath2 prefetchPath)
at ProjectHelpers.Extensions.SurveyResponseSaveHelper.AfterSave(EntityBase2 entity, DataAccessAdapterBase adapter)
at SS2.RemoteObjects.DataPortal.EntitySaveWithoutRemoting(EntityBase2 entity, AuditSettings auditSettings, AuthTicket at) [NDC:(null)]
Here is the method in the reflected object that bombs:
public EntityBase2 AfterSave(EntityBase2 entity, DataAccessAdapterBase adapter)
{
SurveyResponseEntity response = entity as SurveyResponseEntity;
if (response.IsComplete) // we only really want to do this if the survey has been completed.
{
SurveyEntity survey = new SurveyEntity(response.SurveyRefId);
IPrefetchPath2 questionSetPath = new PrefetchPath2((int)SS2DAL.EntityType.SurveyEntity);
IPredicateExpression filter = new PredicateExpression(QuestionSetFields.Current == 1);
questionSetPath.Add(SurveyEntity.PrefetchPathQuestionSetCollection, 1, filter)
.SubPath.Add(QuestionSetEntity.PrefetchPathQuestionPageCollection)
.SubPath.Add(QuestionPageEntity.PrefetchPathQuestionCollection);
if (adapter.FetchEntity(survey, questionSetPath))
{
// we need to instantiate the survey template save handler from this survey response (if it exists)
// then execute
if (!String.IsNullOrEmpty(survey.PostSaveAssemblyName) && !String.IsNullOrEmpty(survey.PostSaveClassName))
{
try
{
string assemblyPath = (new FileService()).GetRootAssemblyURL();
Assembly asm = Assembly.Load(File.ReadAllBytes(Path.Combine(assemblyPath, survey.PostSaveAssemblyName)));
if (asm != null)
{
Type t = asm.GetType(survey.PostSaveClassName);
ISurveyPostSaveHandler cls = (ISurveyPostSaveHandler)Activator.CreateInstance(t);
if (cls != null)
{
cls.AfterSave(response, survey, adapter);
}
}
}
catch (Exception ex)
{
// at some point, we need to add some logging here.
Logger.ErrorFormat("There was an error post-processing survey response {0} from survey {1}: {2}", response.SurveyResponseId, survey.Name, ex.ToString());
throw ex;
}
}
}
else
{
Logger.ErrorFormat("Could not post process response {0} because the parent survey could not be located", response.SurveyResponseId);
throw new ApplicationException(String.Format("Could not post process response {0} because the parent survey could not be located", response.SurveyResponseId));
}
}
return response;
}
#endregion
}

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".

Resources