Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebActivator2.2 Package error #35

Closed
csanghavi opened this issue Nov 7, 2020 · 5 comments
Closed

WebActivator2.2 Package error #35

csanghavi opened this issue Nov 7, 2020 · 5 comments

Comments

@csanghavi
Copy link

csanghavi commented Nov 7, 2020

While using your 2.2 version through Nuget, I am getting following Exception. This is kind of show stopper for our project.

I have following observations on this issue:

  1. I have added WebActivatorEx Package Version 2.2 using nuget package manager under my project.
  2. I have added WebActivator.dll in Project reference and using it in our startup class.
  3. I verified that packages.config file has reference for this package.

I have searched on StackOverflow and found the very old discussion..
jetheredge/SquishIt#327
This does not solve my problem.

Exception information:

    Exception type: FileNotFoundException 
    **Exception message: Could not load file or assembly 'WebActivatorEx, Version=2.0.0.0, Culture=neutral,** PublicKeyToken=7b26dc2a43f6a0d4' or one of its dependencies. The system cannot find the file specified.
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type)
   at System.ModuleHandle.ResolveTypeHandleInternal(RuntimeModule module, Int32 typeToken, RuntimeTypeHandle[] typeInstantiationContext, RuntimeTypeHandle[] methodInstantiationContext)
   at System.Reflection.RuntimeModule.ResolveType(Int32 metadataToken, Type[] genericTypeArguments, Type[] genericMethodArguments)
   at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(CustomAttributeRecord caRecord, MetadataImport scope, Assembly& lastAptcaOkAssembly, RuntimeModule decoratedModule, MetadataToken decoratedToken, RuntimeType attributeFilterType, Boolean mustBeInheritable, Object[] attributes, IList derivedAttributes, RuntimeType& attributeType, IRuntimeMethodInfo& ctor, Boolean& ctorHasParameters, Boolean& isVarArg)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean mustBeInheritable, IList derivedAttributes, Boolean isDecoratedTargetSecurityTransparent)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeModule decoratedModule, Int32 decoratedMetadataToken, Int32 pcaCount, RuntimeType attributeFilterType, Boolean isDecoratedTargetSecurityTransparent)
   at System.Reflection.CustomAttribute.GetCustomAttributes(RuntimeAssembly assembly, RuntimeType caType)
   at System.Reflection.RuntimeAssembly.GetCustomAttributes(Boolean inherit)
   at Owin.Loader.DefaultLoader.SearchForStartupAttribute(String friendlyName, IList`1 errors, Boolean& conflict)
   at Owin.Loader.DefaultLoader.GetDefaultConfiguration(String friendlyName, IList`1 errors)
   at Owin.Loader.DefaultLoader.LoadImplementation(String startupName, IList`1 errorDetails)
   at Owin.Loader.DefaultLoader.Load(String startupName, IList`1 errorDetails)
   at Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup()
   at Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint()
   at System.Threading.LazyInitializer.EnsureInitializedCore[T](T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory)
   at Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context)
   at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
   at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
   at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
   at System.Web.HttpApplicationFactory.GetPipelineApplicationInstance(IntPtr appContext, HttpContext context)
   at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

Your earliest help will help us get going on using this. Please contact me at my email address .

Regards,
Chandresh Sanghavi

@davidebbo
Copy link
Owner

Are you able to repro this issue in a minimal app (e.g. clean new MVC app)? If not, then please isolate to try to understand what may be different in yours.

@csanghavi
Copy link
Author

csanghavi commented Nov 8, 2020

Hello and Thank you very much for your prompt response !!

I did work on basic mvc and I am not able to reproduce.

However, my scenario is little different. I have two web applications and I have used this call for using a startup method in the first web application and then I send WebApi request to second Web Application and it throws 500 error while initializing the code from Global.asax of second application. I am really not sure why it should throw error while calling the web api of second application (where there is no use of WebactivatorEx). Here is the Code Snippet of two web applications

Web Application 1

in file ReactConfig.cs

[assembly: WebActivatorEx.PreApplicationStartMethod(typeof(MyAssemblyWebsite1.ReactConfig), "Configure")]
namespace MyAssemblyWebsite1
{
	public static class ReactConfig
	{
		public static void Configure()
               ...
         }
}

MyHomeController.cs

Login() 
{
      var user = myHttpClient.SendAsync("api/MyWebSite2Home?userId=....");
}

Web Application 2
Global.asax.cs
Some initialization Code

MyWebSite2HomeController.cs

 [HttpGet]
 public IdentityUser FindByIdAsync(string userId)
 {  ... }

So, when the WebApi Rquest is made, it throws 500 error with the above exception.

So, to summarize - the WebActivatorEx is only used for specific Startup method for Web Site1 and exception is coming up while connecting to second site (while loading code)

Now there are two weird results that I noticed :
1) If I put the WebActivatorex.dll in the Second WebSite's bin folder.. all work fine..

2) The Same code being also tested today on another machine and everything worked without this extra copy of WebActivatorEx into second site bin folder.

@davidebbo
Copy link
Owner

Based on your 2), could it be that on the machine where it repros, there are files that are in a dirty state? But if you do a clean deployment, it would work there as well, as it does on your second machine?

@csanghavi
Copy link
Author

I cleared the VS Component Cache and working fine now. Thanks !

@davidebbo
Copy link
Owner

Glad to hear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants