AppHarbor Error .NET 4.5 .asmx has not been pre-compiled, and cannot be requested - .net-4.5

I would like this old school .asmx file to work with .NET 4.5 on AppHarbor but its giving me this error which I don't see locally. Any ideas?
Is it because I recently moved to target .NET 4.5? The rest of the app is fine.
.asmx has not been pre-compiled, and cannot be requested.
Here is some stack trace
System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +692
System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate) +103
System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate) +48
System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath) +16

In case anyone comes across this... I ended up re-writing the .asmx functionality (I only had one anyway) into WebApi which was on my to do list... so I just bumped it up to priority one and got rid of the old technology entirely.
Also of note was that I needed to add a .gitignore file to the root of my project which I ended up doing like this...
bin/*.dll
obj/*.dll
obj/Debug/*.dll
obj/Debug/TempPE/*.dll

Related

SqlPackage Object reference not set to an instance of an object

When I attempt to deploy DACPACs via SqlPackage.exe,
I encounter the error below :
An unexpected failure occurred: Object reference not set to an instance of an object..
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.Sql90TableBaseColumnPopulator`1.InsertElementIntoParent(SqlColumn element, TElement parent, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.ChildModelElementPopulator`2.CreateChildElement(TParent parent, EventArgs e, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.ChildModelElementPopulator`2.PopulateAllChildrenFromCache(IDictionary`2 cache, SqlReverseEngineerRequest request, OrdinalSqlDataReader reader, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.ReverseEngineerPopulators.TopLevelElementPopulator`1.Populate(SqlReverseEngineerRequest request, OrdinalSqlDataReader reader, ReverseEngineerOption option)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.ExecutePopulators(ReliableSqlConnection conn, IList`1 populators, Int32 totalPopulatorsCount, Int32 startIndex, Boolean progressAlreadyUpdated, ReverseEngineerOption option, SqlReverseEngineerRequest request)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.ExecutePopulatorsInPass(SqlReverseEngineerConnectionContext context, ReverseEngineerOption option, SqlReverseEngineerRequest request, Int32 totalCount, Tuple`2[] populatorsArray)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineerImpl.PopulateBatch(SqlReverseEngineerConnectionContext context, SqlSchemaModel model, ReverseEngineerOption option, ErrorManager errorManager, SqlReverseEngineerRequest request, SqlImportScope importScope)
at Microsoft.Data.Tools.Schema.Sql.SchemaModel.SqlReverseEngineer.PopulateAll(SqlReverseEngineerConnectionContext context, ReverseEngineerOption option, ErrorManager errorManager, Boolean filterManagementScopedElements, SqlImportScope importScope, Boolean optimizeForQuery, ModelStorageType modelType)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.ImportDatabase(SqlReverseEngineerConstructor constructor, DeploymentEngineContext context, ErrorManager errorManager)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeploymentEndpointServer.OnLoad(ErrorManager errors, DeploymentEngineContext context)
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.PrepareModels()
at Microsoft.Data.Tools.Schema.Sql.Deployment.SqlDeployment.InitializePlanGeneratator()
at Microsoft.SqlServer.Dac.DacServices.<>c__DisplayClass21.<CreateDeploymentArtifactGenerationOperation>b__1f(Object operation, CancellationToken token)
at Microsoft.SqlServer.Dac.Operation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.ReportMessageOperation.Microsoft.SqlServer.Dac.IOperation.Run(OperationContext context)
at Microsoft.SqlServer.Dac.OperationExtension.Execute(IOperation operation, DacLoggingContext loggingContext, CancellationToken cancellationToken)
at Microsoft.SqlServer.Dac.DacServices.GenerateDeployScript(DacPackage package, String targetDatabaseName, DacDeployOptions options, Nullable`1 cancellationToken)
at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.<>c__DisplayClasse.<DoDeployAction>b__4(DacServices service)
at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.ExecuteDeployOperation(String connectionString, String filePath, MessageWrapper messageWrapper, Boolean sourceIsPackage, Boolean targetIsPackage, Func`1 generateScriptFromPackage, Func`2 generateScriptFromDatabase)
at Microsoft.Data.Tools.Schema.CommandLineTool.DacServiceUtil.DoDeployAction(DeployArguments parsedArgs, Action`1 writeError, Action`2 writeMessage, Action`1 writeWarning)
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.DoDeployActions(CommandLineArguments parsedArgs)
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Run(String[] args)
at Microsoft.Data.Tools.Schema.CommandLineTool.Program.Main(String[] args)
Below is the command I run:
SET vardeploy2=/Action:Script
set varBlockOnDriftParameter=/p:BlockWhenDriftDetected=False
"SSDTBinaries\SqlPackage.exe" %vardeploy2% %varBlockOnDriftParameter% /SourceFile:"dacpacs\DBName.dacpac" /Profile:"Profiles\%1.DBName.Publish.xml" >> Log.txt 2>>&1
I deploy to a SQL Server 2008 R2. The SqlPackage.exe version is 11.0.2820.0.
The issue is intermittent, which suggests it's not related to the DACPAC being deployed or the destination database's schema. My best guess is that something about the state of the database is causing the problem.
Still, I haven't been able to identify anything unusual at the time of the failures.
When recreating the issue locally, using schema locks results in a different error message.
Has anyone know of a solution?
Upgrade to a more resent SQL Server Data Tools.

"An unexpected error ocurred" CRM2015 OnPremise Plugins

For 2 weeks we have been experiencing a small totally random issue with plugins in CRM 2015 OnPremise. When we make an upload, randomly and without much sense (at least according to analyze all code does not) plugins are throwing us the following exception:
The Web Service plug-in failed in OrganizationId:
fb2630bc-8dc1-e411-80be-bae05bad392c; SdkMessageProcessingStepId:
d2713f4e-51b7-e411-80b8-527d00dcf108; EntityName: new_serviciobase;
Stage: 30; MessageName: Create; AssemblyName:
Microsoft.Crm.Extensibility.InternalOperationPlugin,
Microsoft.Crm.ObjectModel, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35; ClassName:
Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception:
Unhandled Exception: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation.
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 System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object
target, Object[] values)
at
Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider
serviceProvider)
at
Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext
context)
at
Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext
context)
Inner Exception: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type,
Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly,
Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at
Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.InitializePlugin[T](IOrganizationContext
context, StepDescription stepDescription, SecureConfigurationCache
stepSecureConfigurationCache, Type type)
at Microsoft.Crm.Extensibility.V5PluginProxyStep..ctor(Guid stepId,
SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog
eventLog, IOrganizationContext context)
at Microsoft.Crm.Extensibility.PluginStep..ctor(Guid stepId,
SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog
eventLog, IOrganizationContext context)
at
Microsoft.Crm.Extensibility.PipelineStepFactory.CreateInstance(Guid
stepId, IOrganizationContext context)
at Microsoft.Crm.Caching.PipelineStepCacheLoader.LoadCacheData(Guid
key, ExecutionContext context)
at
Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key,
IOrganizationContext context)
at
Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.CreateEntry(TKey key,
IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey
key, IOrganizationContext context)
at
Microsoft.Crm.Caching.MessageProcessorCacheLoader.GetCustomizationLevel(MessageProcessor
mp, ExecutionContext context)
at
Microsoft.Crm.Caching.MessageProcessorCacheLoader.LoadCacheData(MessageProcessorKey
key, ExecutionContext context) at
Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key,
IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey
key, IOrganizationContext context)
at
Microsoft.Crm.Extensibility.InternalMessageDispatcher.TryGetMessageProcessor(MessageProcessorKey
key, ExecutionContext context)
at
Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.IsPipelineDefined(MessageProcessorKey
key, ExecutionContext context)
at
Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.CreateWithInvocationSource(BusinessEntity
entity, Int32 invocationSource, ExecutionContext context)
at
Microsoft.Crm.BusinessEntities.BusinessProcessObject.Create(IBusinessEntity
entity, ExecutionContext context)
Inner Exception: System.IO.FileLoadException: Could not load file or
assembly ‘SCM.CRM.Core, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=369abd01f82b8d9d’ or one of its dependencies. Access is
denied.
at SCM.CRM.Plugins.Plugin..ctor(Type childClassName)
at SCM.CRM.Plugins.PLGServicioBase..ctor()
It brings a little headache because we don't understand what happened, just that sometimes fails and sometimes not ... we have a custom library registered plugins (disk) "SCM.Core.dll" to which says itself unable to access ... Any ideas?
As #Sxntk said, you need to make sure you merge any plugins with ilmerge if you are using Sandbox mode isolation mode when registering the plugin assembly.
If you have an isolation mode of 'none', make sure the assembly is in the GAC or placed in the bin\assembly folder in the CRM installation directory on the server.
Hopefully this helps.
I'm a coleague of Alexis, and now we have more details thanks to crmdiagtool:
System.IO.FileLoadException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #ED0C936C: System.IO.FileLoadException: Could not load file or assembly 'SCM.CRM.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=369abd01f82b8d9d' or one of its dependencies. Access is denied.
File name: 'SCM.CRM.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=369abd01f82b8d9d'
You can do the following thing:
make sure all your referenced assemblies have "Copy Local" set to "True"
unload the project from visual studio
right click on the unloaded project and edit the csproj file
add the following lines in the csproj file right before the "Project" end tag (before last line in the document):
<Target Name="AfterResolveReferences">
<ItemGroup>
<EmbeddedResource Include="#(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
<LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Target>
add this method to the plugin class:
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
AssemblyName assemblyName = new AssemblyName(args.Name);
string path = assemblyName.Name + ".dll";
if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false)
{
path = String.Format(#"{0}\{1}", assemblyName.CultureInfo, path);
}
using (Stream stream = executingAssembly.GetManifestResourceStream(path))
{
if (stream == null)
return null;
byte[] assemblyRawBytes = new byte[stream.Length];
stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length);
return Assembly.Load(assemblyRawBytes);
}
}
add the following constructor to the plugin class:
static [Constructor name]()
{
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
}
rebuild and register your plugin
Doing this, all the referenced assemblies that are copied locally to your bin folder are packed into the main dll. The drawback is that you could end up having such a huge dll that you can not register it as a plugin.
Hope this helps,
Cheers

ADO.Net Entity Framework Thread abort exception while reading the data

I am facing a strange issue while reading a data using ADO.Net Entity framework.
I have two tables, "Surveys" and "PatientVists". "VisitId" is the primary key in "PatientVists" which is foreign key in "surveys" table.
I am using following query:
foreach (var survey in db.Surveys.Include(p => p.PatientVisit).Where(p => p.FacilityId == f.Id && p.IsCompleted == true && p.IsImaged == false).OrderBy(p => p.PatientVisit.MrnId).ThenBy(p => p.DateUpdated).ToList())
{
// reminign code
}
The above query seems pretty normal. But while executing the query I am getting thread abort exception. I can understand if I get timeout exception because of the large amount of the data. But I am not sure why I am getting thread abort exception. I am not explicitly spawning a thread. this code snippet is in the web service but I believe it's not related to that.
Following is the stack trace:
System.Threading.ThreadAbortException: Thread was being aborted.
at SNIReadSyncOverAsync(SNI_ConnWrapper* , SNI_Packet** , Int32 )
at SNINativeMethodWrapper.SNIReadSyncOverAsync(SafeHandle pConn, IntPtr& packet, Int32 timeout)
at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
Is it reelected "ToList" operator or does "include" operator spawns a thread? Shall I replace it with Join? in general which is preferred method from performance perspective?
Please let me know if anyone has an insight into the particular exception
Thanks
I think this is the base thread that services the web application / service that is being timed out. If you spawn the process on its own thread, it should solve the problem.
You can also try the workaround posted here:
https://sharepoint.stackexchange.com/questions/9380/thread-was-being-aborted-with-sharepoint-2010
Add the code below to Web.Config:
< system.web >
< httpRuntime executionTimeout="36000" />
< / system.web >
It worked for me as a temporary solution until I change the code to run in its own thread!

Multiple odata webapi controllers with the same resultset

I need to create two odata controllers that return the same result set.
Specifically, the result sets is returned from two stored procedures, which receive a lot of parameters, and do some heavy processing on server.
Both SPs receive exact the same params and return the same data, but they accomplish the search in different ways, and I need to do this for some performance tests and comparisons.
The SPs are mapped to functions in EF.
So I need to have two odata controllers that, each of them, call a different SP, but return the same data type.
My code is as follows:
Controller 1
<Authorize>
Public Class SearchController
Inherits ODataController
Private _dc As New ModelDC
' GET odata/Search
<Queryable>
Function GetSearch(<FromURI> search As SearchParam) As IQueryable(Of SearchResult)
dim result = _dc.Search(search.Parm1, search.Param2, ...).ToList
Return result.AsQueryable
end function
Controller 2
<Authorize>
Public Class SearchV2Controller
Inherits ODataController
Private _dc As New ModelDC
' GET odata/Search
<Queryable>
Function GetSearch(<FromURI> p1 as string, <FromURI> p2 as string, ...) As IQueryable(Of SearchResult)
dim result = _dc.SearchV2(p1, p2, ...).ToList
Return result.AsQueryable
end function
And the odata route registration in WebApiConfig.Register
Dim builder As New ODataConventionModelBuilder
builder.EntitySet(Of SearchResult)("Search")
config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel())
builder = New ODataConventionModelBuilder
builder.EntitySet(Of SearchResult)("SearchV2")
config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel())
However, when I start the app, I get the following error:
Server Error in '/' Application. Exception of type
'System.OutOfMemoryException' was thrown. 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.OutOfMemoryException: Exception of type
'System.OutOfMemoryException' was thrown.
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:
[OutOfMemoryException: Exception of type 'System.OutOfMemoryException'
was thrown.] System.Reflection.RuntimeAssembly._nLoad(AssemblyName
fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly
locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder,
Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String
codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) +34
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly,
StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean
throwOnFileNotFound, Boolean forIntrospection, Boolean
suppressSecurityChecks) +152
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr
pPrivHostBinder, Boolean forIntrospection) +77
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,
Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean
forIntrospection) +16 System.Reflection.Assembly.Load(String
assemblyString) +28
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
assemblyName, Boolean starDirective) +38
[ConfigurationErrorsException: Exception of type
'System.OutOfMemoryException' was thrown.]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
assemblyName, Boolean starDirective) +736
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
+217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo
ai) +130
System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection
compConfig) +170
System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()
+91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String
preStartInitListPath, Boolean& isRefAssemblyLoaded) +284
System.Web.Compilation.BuildManager.ExecutePreAppStart() +153
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost, IConfigMapPathFactory
configMapPathFactory, HostingEnvironmentParameters hostingParameters,
PolicyLevel policyLevel, Exception appDomainCreationException) +521
[HttpException (0x80004005): Exception of type
'System.OutOfMemoryException' was thrown.]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +9930508
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)
+101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +254
What is the problem?
Is it the fact that both controllers are defined with the same return type?
I can, of course, create a different entity for the second SP (with exact the same structure), and map the result of each SP to different result class, and I assume that will work, but I prefer to have them both returning the same type of result.
What am I doing wrong?
Thanks
PS. I have the result converted first ToList and then returned AsQueryable because I need to support $inlinecount odata param, and EF-mapped SPs uses DataReader inside, which doesn't allow to re-enumerate the set to get the count first and then return the actual data. If anyone has a better idea to handle this, please let me know also.
why do you map the same route with different Edm Model? Can you merge them together as?
Dim builder As New ODataConventionModelBuilder
builder.EntitySet(Of SearchResult)("Search")
builder.EntitySet(Of SearchResult)("SearchV2")
config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel())

MVC Routing and Custom Error Page Not Found Problem

I am using my own controller factory in an MVC 2 app, and this standard code which seems to be going around:
protected override IController GetControllerInstance(RequestContext reqContext, Type controllerType)
{
...
// Error handling
if (controllerType == null)
{
throw new HttpException(
404, String.Format(
"The controller for path '{0}' could not be found" +
" or it does not implement IController.",
reqContext.HttpContext.Request.Path
)
);
}
...
}
The problem I was having is one others have asked about, where certain resources where being caught by this error handling logic and my ELMAH has been getting populated with hundreds of pointless errors. More annoyingly, it makes debugging painful to have to keep F5-ing the errors. These resources are: favicon.ico, Error.aspx (my custom error page), and some images in a particular folder.
So I followed the advice of this post, and attempted to solve the issues through ignoring routes in the global.asax:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("elmah.axd");
routes.IgnoreRoute("/Content/images/{*pathinfo}"); // This has succesfully rid me of a bunch of errors
routes.IgnoreRoute("{*favicon}", new { favicon = #"(.*/)?favicon.([iI][cC][oO]|[gG][iI][fF])(/.*)?" }); // This has successfully rid me of the favicon error
routes.IgnoreRoute("{*allaspx}", new { allaspx = #"(.*/)?.aspx(/.*)?" }); // NOT SURE OF THIS ONE
...
);
}
As I've mentioned in the comments, this has cleared up many of the errors. The problem I now have is that when I start the application, I'm immediatley given a 404 screen of death, telling me my custom error page cannot be found. The error details:
System.Web.HttpException (0x80004005): The file '/Error.aspx' does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean throwIfNotFound)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
And the web config section:
<system.web>
<customErrors mode="On" defaultRedirect="Error.aspx" />
...
</system.web>
The error page was working just fine before I made the changes to the routing. If I comment out the /content/images path - the app works again (though I'm back to "The controller for path '{0}' could not be found or it does not implement IController" errors). Commenting out the favicon or allaspx route has no change on this 404 error.
Any help would be greatly appreciated.
Cheers,
Tim.
The issue was badly setup error page.
I went back to the very beginning, and this tutorial. I did not have an ErrorController and was using the HandleError attribute. Following the instructions in this link fixed it up the problems with the error page. The answer to ignore routes worked for the favicon. The other files were genuinely missing files.
We got the same error message, but issue was different, the optional parameter we were passing contains / character, which causes the application to look for different routing. So please verify that your parameter doesn't contain / character.