NotSupportedException is thrown when trying to save Emitted assembly - c#

http://pastebin.com/n6G1jTHQ
My code creates a new assembly and module, and then emits a class SWT(within a new assembly) that should be exactly the same as SWTTFieldsclass.
Line 137, saves the assembly/module into a .dll, myAsmBuilder.Save("ModuleOne.dll"); throws the exception:
An unhandled exception of type 'System.NotSupportedException' occurred
in mscorlib.dll Additional information: Type 'SWT' was not completed.
Why I am getting this error ? What is missing in my emitted class ?

You have to call the TypeBuilder.CreateType Method for each TypeBuilder before saving the File.

Related

An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributo

when i create new project anglar and run the app i get this err
An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.OpenIddict.AbpOpenIddictDomainModule, Volo.Abp.OpenIddict.Domain, Version=7.0.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating Volo.Abp.OpenIddict.Tokens.TokenCleanupBackgroundWorker -> Volo.Abp.DistributedLocking.MedallionAbpDistributedLock.. See the inner exception for details.
Autofac.Core.DependencyResolutionException: An exception was thrown while activating Volo.Abp.OpenIddict.Tokens.TokenCleanupBackgroundWorker -> Volo.Abp.DistributedLocking.MedallionAbpDistributedLock.
Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Volo.Abp.DistributedLocking.MedallionAbpDistributedLock' can be invoked with the available services and parameters:
Cannot resolve parameter 'Medallion.Threading.IDistributedLockProvider distributedLockProvider' of constructor 'Void .ctor(Medallion.Threading.IDistributedLockProvider, Volo.Abp.Threading.ICancellationTokenProvider, Volo.Abp.DistributedLocking.IDistributedLockKeyNormalizer)'.
v
Make sure you are running Redis. DistributedLocking refers to Redis in your error.

how to load sharepoint.client assembly during run time in c#

Hi I have ben trying to load sharepoint assembly during runtime, But i am always getting the error
"Exception thrown: 'System.Reflection.ReflectionTypeLoadException' in mscorlib.dll
"
here i my code snippet
Assembly assembly = Assembly.LoadFile(extension);
Type type = assembly.GetType("Microsoft.SharePoint.Client.File");
var obj = Activator.CreateInstance(type);
Also if i wish to know all the method names then ho would i do it?
Please help!!!
You can get the exact contained types with Assembly.GetExportedTypes().
With Type.GetMethods() you can get all the methods of a type.

Microsoft.CognitiveServices.Speech is not working after publishing application

Getting following exception when loading :
speechRecognizer = new Microsoft.CognitiveServices.Speech.SpeechRecognizer(config);
Inner exception : InnerException = {"Unable to load DLL
'Microsoft.CognitiveServices.Speech.csharp.bindings.dll': The
specified module could not be found. (Exception from HRESULT:
0x8007007E)"}
Microsoft.CognitiveServices.Speech.Internal.carbon_csharpPINVOKE.SpeechConfig_FromSubscription(String
jarg1, String jarg2) at
Microsoft.CognitiveServices.Speech.Internal.SpeechConfig.FromSubscription(String
subscription, String region) at
Microsoft.CognitiveServices.Speech.SpeechConfig.FromSubscription(String
subscriptionKey, String region) |ERROR|The type initializer for
'SWIGExceptionHelper' threw an exception. 2019-01-03
16:02:50.2178|ERROR|The type initializer for
'Microsoft.CognitiveServices.Speech.Internal.carbon_csharpPINVOKE'
threw an exception.
As the exception says, you are missing "Microsoft.CognitiveServices.Speech.csharp.bindings.dll" . You have to include the dll in the project and mark it as part of the deploy. Make sure it appears in the deployed folder in the IIS , copy it manually as last option.

unhandled exception of type 'System.AccessViolationException' occurred while using 2 include in a EF query

I added the second Include to my EF query
return entities.lnkAnimalSubCategories.Where(t => t.tblVersie.Naam.Equals(webVersie)).Include("tblAnimalSubCategorie").Include("tblStal").ToList();
and I got this error:
An unhandled exception of type 'System.AccessViolationException'
occurred in Unknown Module.Attempted to read or write protected
memory. This is often an indication that other memory is corrupt.
Does anyone know why I am having this error?
The problem was : Json could not handle circular object references.
To fix that, I added the following code in Global.asax
var json = GlobalConfiguration.Configuration.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Array;

Rebuilding the AddressBook example in protobuf-csharp-port 2.4.1.473

I have sucessfully built the example AddressBook project in protobuf-csharp-port-2.4.1.473-source and have even got it to work with the C++ example from the protobuf-2.4.1-win32. However, when I try to regenerate the AddressBookProtos.cs file and execute it, I encounter the following runtime problem.
Options:
L: List contents
A: Add new person
Q: Quit
Action? a
Exception executing action: System.TypeInitializationException: The type initializer
for 'Google.ProtocolBuffers.Examples.AddressBook.AddressBook' threw an exception. --->
System.TypeInitializationException: The type initializer
for 'Google.ProtocolBuffers.Examples.AddressBook.AddressBookProtos' threw an exception. --->
System.ArgumentException: Invalid embedded descriptor for "tutorial/addressbook.proto". --->
Google.ProtocolBuffers.Descriptors.DescriptorValidationException: tutorial/addressbook.proto:
Dependencies passed to FileDescriptor.BuildFrom() don't match those listed in the
FileDescriptorProto.
at Google.ProtocolBuffers.Descriptors.FileDescriptor.BuildFrom(FileDescriptorProto proto,
FileDescriptor[] dependencies)
at Google.ProtocolBuffers.Descriptors.FileDescriptor.InternalBuildGeneratedFileFrom(Byte[]
descriptorData, FileDescriptor[] dependencies, InternalDescriptorAssigner descriptorAssigner)
I tried to generate the AddressBookProtos.cs from protobuf-csharp-port-2.4.1.473-release-binaries, using protos\tutorial\addressbook.proto but it seems to be missing the namespace and umbrella_classname options. Also, the version numbers listed in src\AddressBook\AddressBookProtos.cs that came in protobuf-csharp-port-2.4.1.473-source says it is "2.3.0.277".

Categories

Resources