Particular / NServiceBus.Azure

Transports and storage for Windows Azure
https://docs.particular.net/nservicebus/azure/
Other
10 stars 15 forks source link

NServiceBusRoleEntrypoint constructor throws assembly scanning errors #235

Closed abeven closed 9 years ago

abeven commented 9 years ago

This can be a problem - for example, I'm working with some legacy assemblies and there's types that with dead code missing the [SecurityCritical] attribute. I know those assemblies don't have any types interesting to NSB anyway, so I'd like to exclude them in my BusConfiguration.

But GenericHost runs a scan before loading the config.

Any thoughts on how to work around?

yvesgoeleven commented 9 years ago

Which version are you on? This issue should have been fixed: as from 5.3.4

https://github.com/Particular/NServiceBus.Azure/issues/168

abeven commented 9 years ago

It's 6.1.2.

Here's the full stack trace:

Microsoft.WindowsAzure.ServiceRuntime Critical: 201 : Role entrypoint could not be created: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Exception: Could not enumerate all types for 'C:\git\md\Services.Azure\csx\Debug\roles\Notifications\approot\RazorEngine.dll'. Exceptions: System.TypeLoadException: Inheritance security rules violated while overriding member: 'RazorEngine.Templating.TemplateParsingException.GetObjectData(System.Runtime.Serialization.SerializationInfo, System.Runtime.Serialization.StreamingContext)'. Security accessibility of the overriding method must match the security accessibility of the method being overriden.

at NServiceBus.Hosting.Helpers.AssemblyScanner.ScanAssembly(String assemblyPath, AssemblyScannerResults results) in c:\BuildAgent\work\1b05a2fea6e4cd32\src\NServiceBus.Core\Hosting\Helpers\AssemblyScanner.cs:line 157 at NServiceBus.Hosting.Helpers.AssemblyScanner.GetScannableAssemblies() in c:\BuildAgent\work\1b05a2fea6e4cd32\src\NServiceBus.Core\Hosting\Helpers\AssemblyScanner.cs:line 63 at NServiceBus.Hosting.Azure.GenericHost..ctor(IConfigureThisEndpoint specifier, String[] args, List1 defaultProfiles, IEnumerable1 scannableAssembliesFullName) in c:\BuildAgent\work\9e81da84cea5f13f\src\NServiceBus.Hosting.Azure\GenericHost.cs:line 43 at NServiceBus.Hosting.Azure.NServiceBusRoleEntrypoint..ctor() in c:\BuildAgent\work\9e81da84cea5f13f\src\NServiceBus.Hosting.Azure\RoleHost\Entrypoint.cs:line 37 at Notifications.WorkerRole..ctor() in c:\git\md\Notifications\WorkerRole.cs:line 18 --- End of inner exception stack trace --- 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.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum) at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum) The program '[33336] WaWorkerHost.exe' has exited with code -1 (0xffffffff).

yvesgoeleven commented 9 years ago

Looks like the patch I mentioned earlier was not applied on one place, I'll apply it and prepare a new version for you

yvesgoeleven commented 9 years ago

I've just pushed version 6.1.3 to nuget, which should now allow you to exclude those assemblies

yvesgoeleven commented 9 years ago

@abeven did this patch resolve your issue?

abeven commented 9 years ago

It did! Thank you very much.

On Thu, Jan 8, 2015 at 8:02 AM, Yves Goeleven notifications@github.com wrote:

@abeven https://github.com/abeven did this patch resolve your issue?

— Reply to this email directly or view it on GitHub https://github.com/Particular/NServiceBus.Azure/issues/235#issuecomment-69176060 .

jberke commented 9 years ago

Was this applied to NServiceBus.Host? I'm getting a simillar error in that NServiceBus appears to be scanning and loading assemblies it shouldn't. I have 6.0.0 for Host and 5.1.3 for nServiceBus is there a nuget for 5.3?

yvesgoeleven commented 9 years ago

It's applied to host version 6.0.5 as well, can you try upgrading? Or are you referring to the regular nsbhost (not clear to me which host you are using)

jberke commented 9 years ago

I dont see a 6.0.5 nuget. I resolved this by setting the specific assembly to scan.

Id rather have it scan however On Jan 27, 2015 3:58 PM, "Yves Goeleven" notifications@github.com wrote:

It's applied to host version 6.0.5 as well, can you try upgrading?

— Reply to this email directly or view it on GitHub https://github.com/Particular/NServiceBus.Azure/issues/235#issuecomment-71726385 .