How to "Enhance" assembly for dynamic types and OpenAccess?
I have create a "Sitefinity Intermediate Module" from the Visual Studio templates. I copied the Job and Products samples, but fails to install because I keep hitting this runtime error for my module:
System.Reflection.TargetInvocationException was unhandled by user code
Message=Exception has been thrown by the target of an invocation.
Source=mscorlib
StackTrace:
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)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance[T]()
at Telerik.Sitefinity.Data.ManagerBase`1.GetManager[T](String providerName, String transactionName)
at Telerik.Sitefinity.Data.ManagerBase`1.GetManager[T](String providerName)
at MySampleSpace.Samples.SamplesManager.GetManager(String providerName)
InnerException: System.Configuration.ConfigurationErrorsException
Message=Telerik.OpenAccess: No enhanced assembly has been found for meta-data construction. This may be caused by a missing app.config file (use app.config as embedded resource then) or by an insufficient references section in the configuration file (add the referenced enhanced assemblies there too) or by a wrong enhancement setting; please check your configuration.
Source=Unity_ILEmit_DynamicClasses
BareMessage=Telerik.OpenAccess: No enhanced assembly has been found for meta-data construction. This may be caused by a missing app.config file (use app.config as embedded resource then) or by an insufficient references section in the configuration file (add the referenced enhanced assemblies there too) or by a wrong enhancement setting; please check your configuration.
Line=0
StackTrace:
at DynamicModule.ns.Wrapped_OpenAccessSamplesDataProvider_5dd14aa3d8aa4957a518d2e18d57cdbb.Initialize(String providerName, NameValueCollection config, Type managerType)
at Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, Type providerType, ExceptionPolicyName policy, ManagerBase`1 manager)
at Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, ExceptionPolicyName policy, ManagerBase`1 manager)
at Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName)
at Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName, String transactionName)
at Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName)
at Telerik.Sitefinity.Modules.GenericContent.ContentManagerBase`1..ctor(String providerName)
at MySampleSpace.Samples.SamplesManager..ctor(String providerName)
at MySampleSpace.Samples.SamplesManager..ctor()
InnerException:
Hello Basem,
There are several possible causes of the problem.
First if you have copies the products and jobs module it is possible that the project looks for the VEnhance of OpenAccess in the incorrect library. The problem is that once you move the projects out of the SDK folder the relative path to the enhancer becomes wrong. We have resolved the problem on our side and the fix for that will be included in the internal build that we are about to release later today.
If you want to resolve the problem on your end simply correct the paths to the venhancer by editing the .csproj files in visual studio or notepad. The following script will point to the correct Libraries folder if you declare the following property in a property group before the script is called like that:
Declaring the property:
<
LibrariesDir
>$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Telerik\SitefinitySDK\@LibrariesDir)</
LibrariesDir
>
<
Exec
IgnoreExitCode
=
"false"
WorkingDirectory
=
"$(TargetDir)"
Command
=
""$(LibrariesDir)VEnhance.exe" -verboseMode:2 "-config:$(ProjectDir)App.config" -signAssembly "-keyFile:$(ProjectDir)$(AssemblyOriginatorKeyFile)" "-assembly:$(TargetPath)""
Condition
=
"'$(AssemblyOriginatorKeyFile)'!=''"
/>
<
Exec
IgnoreExitCode
=
"false"
WorkingDirectory
=
"$(TargetDir)"
Command
=
""$(LibrariesDir)VEnhance.exe" -verboseMode:2 "-config:$(ProjectDir)App.config" "-assembly:$(TargetPath)""
Condition
=
"'$(AssemblyOriginatorKeyFile)'==''"
/>