System.TypeInitializationException was unhandled during PerformDependencyInjection

Posts   
 
    
like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 01-Jun-2009 14:58:40   

I have an Auditor within my application... all was ok... it was working. I then made some column changes to my database and regenerated the DAL.

Now, at the PerformDependencyInjection call here:

    ''' <summary>Initializes the class members</summary>
        Private Sub InitClassMembers()





            PerformDependencyInjection()
            
            ' __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            ' __LLBLGENPRO_USER_CODE_REGION_END
            OnInitClassMembersComplete()
        End Sub

I get:


System.TypeInitializationException was unhandled
  Message="The type initializer for 'SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton' threw an exception."
  Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20"
  TypeName="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton"
  StackTrace:
       at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton.PerformDependencyInjection(Object injectionTarget)
       at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.PerformDependencyInjection()
       at Fluor.OTA.DAL.EntityClasses.InstallEntityBase.InitClassMembers() in D:\Data\vss\OTA2\OTASolution\DAL\EntityBaseClasses\InstallEntityBase.vb:line 450
       at Fluor.OTA.DAL.EntityClasses.InstallEntityBase.InitClassFetch(String installId, IValidator validator, IPrefetchPath prefetchPathToUse) in D:\Data\vss\OTA2\OTASolution\DAL\EntityBaseClasses\InstallEntityBase.vb:line 431
       at Fluor.OTA.DAL.EntityClasses.InstallEntityBase..ctor(String installId) in D:\Data\vss\OTA2\OTASolution\DAL\EntityBaseClasses\InstallEntityBase.vb:line 82
       at Fluor.OTA.DAL.EntityClasses.InstallEntity..ctor(String installId) in D:\Data\vss\OTA2\OTASolution\DAL\EntityClasses\InstallEntity.vb:line 51
       at Main.UpdateReplicationLabel() in D:\Data\vss\OTA2\OTASolution\OTA\Main.vb:line 31
       at Main.Main_Load(Object sender, EventArgs e) in D:\Data\vss\OTA2\OTASolution\OTA\Main.vb:line 22
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.MethodAccessException
       Message="SD.LLBLGen.Pro.ORMSupportClasses.TypeDiscoverer..ctor()"
       Source="mscorlib"
       StackTrace:
            at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
            at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
            at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
            at System.Activator.CreateInstance(Type type, Boolean nonPublic)
            at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
            at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
            at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
            at System.Activator.CreateInstance(String assemblyName, String typeName)
            at System.AppDomain.CreateInstance(String assemblyName, String typeName)
            at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
            at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
            at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider.Init()
            at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider..ctor()
            at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton..cctor()
       InnerException: System.Security.SecurityException
            GrantedSet="<PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Access="Open"/> <IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Allowed="ApplicationIsolationByUser" UserQuota="512000"/> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execution"/> <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Window="SafeTopLevelWindows" Clipboard="OwnClipboard"/> <IPermission class="System.Security.Permissions.SiteIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Site="tempuri.org"/> <IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PublicKeyBlob="0000000000000000" Name="OTASolution.application" AssemblyVersion="1.0.0.1"/> <IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Url="http://tempuri.org/OTASolution.application"/> <IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Zone="Internet"/> <IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" version="1" Level="SafePrinting"/> <IPermission class="System.Security.Permissions.MediaPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" version="1" Audio="SafeAudio" Video="SafeVideo" Image="SafeImage"/> <IPermission class="System.Security.Permissions.WebBrowserPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" version="1" Level="Safe"/> <IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1"> <ConnectAccess> <URI uri="(http|https)://tempuri\.org/.*"/> </ConnectAccess> </IPermission> </PermissionSet> "
            Message="Request failed."
            PermissionState="<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/> "
            RefusedSet=""
            Source="mscorlib"
            Url=""
            StackTrace:
                 at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
                 at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
                 at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
                 at System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh)
                 at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh)
                 at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
                 at System.Threading.CompressedStack.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
                 at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext)
                 at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant)
            InnerException: 

I've even removed the Auditor.vb class from my project, but still cannot get the application to run.

The exception happens on whichever Entity I intantiate first.

VB 2008 lastest SP/ Access 2003 database/ LLBLGEN 2.6

Deadlines are looming and I'm stuck.

Any suggestions?

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 01-Jun-2009 15:40:23   

How do you decorate your Auditor class with the DI attribute? (please post a code snippet) Also how do you configure DI in the config file? (please post a code snippet) Is this a web app or a windows app?

(EDIT) Please check the folowing thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=11805

like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 01-Jun-2009 15:51:13   


<appSettings>
   ...
<add key="autoDependencyInjectionDiscovery" value="true"/>

...
  </appSettings>


Imports SD.LLBLGen.Pro.ORMSupportClasses
Imports Fluor.OTA.DAL.EntityClasses
Imports Fluor.OTA.DAL.CollectionClasses
Imports System.Collections.Generic


' VB.NET
''' <summary>Example Auditor class which is usable on all entities in a project.</summary>
<DependencyInjectionInfo(GetType(IEntity), "AuditorToUse"), _
Serializable()> _
Public Class OTAAuditor
  Inherits AuditorBase

This is a windows app.

What is strange is that it was working!

Should my the file (Auditing.vb) containing my OTAAuditor class be: Build Action:Compile Copy to Output Directory: Do Not Copy

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 01-Jun-2009 16:14:43   

Either build it into a dll and place it in the output directory of your application. Or configure the DI discovery manually as follows:

<dependencyInjectionInformation>
        <additionalAssemblies>
            <assembly fullName="THE_ASSEMBLY_NAME, Version=1.0.3.4, Culture=neutral, PublicKeyToken=1b72b137335e31c3"/>
        </additionalAssemblies>
    </dependencyInjectionInformation> 

In Visual Studio, the assembly name can be viewed and changed through the project's property pages dialog box Also make sure you are using the correct version and PublicKeyToken.

like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 01-Jun-2009 17:06:07   

I'm sorry Walaa I'm struggling with this:

I've compiled my Auditor class to a .dll

  1. I can't find any mention of PublicKeyToken anywhere within VS.

  2. And to clarify: Which app.config should I be adding the DI settings, the DAL's or the application's

<!--<add key="autoDependencyInjectionDiscovery" value="true"/>-->
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Jun-2009 06:44:35   

like2175 wrote:

  1. I can't find any mention of PublicKeyToken anywhere within VS.

Read the Important Note box here

like2175 wrote:

  1. And to clarify: Which app.config should I be adding the DI settings, the DAL's or the application's
<!--<add key="autoDependencyInjectionDiscovery" value="true"/>-->

It should be at the application's config file (in this case, the app.config of your windows forms app).

Also try to use Manual Discovery instead of autoDiscovery, to see if this makes a difference.

(Edit) Change this

<DependencyInjectionInfo(GetType(IEntity), "AuditorToUse"), _
Serializable()>

into this:

<DependencyInjectionInfo(GetType(IEntity), "Auditor"), _
Serializable()>
David Elizondo | LLBLGen Support Team
like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 04-Jun-2009 15:59:10   

I've tried all suggestions but still no luck.

As soon as the first object in my app is instantiated I get the exception shown at the bottom of this post. Does the detail of the exception below help identify my problem? Is System.Security.PermissionSet a clue?

With the head of my Auditor class looking like this...

'<DependencyInjectionInfo(GetType(PersonEntity), "AuditorToUse"), _
'Serializable()> _
Public Class OTAAuditor
  Implements IAuditor

... the initialization of my ApplicationParametersSingleton appears to be failing even though I believe I am saying 'inject only to PersonEntity'?

(and I still can't find any mention of PublicKeyToken!)

Graham

System.TypeInitializationException was unhandled
  Message="The type initializer for 'ApplicationParametersSingleton' threw an exception."
  Source="OTASolution"
  TypeName="ApplicationParametersSingleton"
  StackTrace:
       at Main.Main_Load(Object sender, EventArgs e) in D:\Data\vss\OTA2\OTASolution\OTA\Main.vb:line 18
       at System.EventHandler.Invoke(Object sender, EventArgs e)
       at System.Windows.Forms.Form.OnLoad(EventArgs e)
       at System.Windows.Forms.Form.OnCreateControl()
       at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
       at System.Windows.Forms.Control.CreateControl()
       at System.Windows.Forms.Control.WmShowWindow(Message& m)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ContainerControl.WndProc(Message& m)
       at System.Windows.Forms.Form.WmShowWindow(Message& m)
       at System.Windows.Forms.Form.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
       at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
       at System.Windows.Forms.Control.set_Visible(Boolean value)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
       at System.Runtime.Hosting.ManifestRunner.Run(Boolean checkAptModel)
       at System.Runtime.Hosting.ManifestRunner.ExecuteAsAssembly()
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext, String[] activationCustomData)
       at System.Runtime.Hosting.ApplicationActivator.CreateInstance(ActivationContext activationContext)
       at System.Activator.CreateInstance(ActivationContext activationContext)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssemblyDebugInZone()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.TypeInitializationException
       Message="The type initializer for 'SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton' threw an exception."
       Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20"
       TypeName="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton"
       StackTrace:
            at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton.PerformDependencyInjection(Object injectionTarget)
            at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.PerformDependencyInjection()
            at Fluor.OTA.DAL.EntityClasses.AppParamEntityBase.InitClassMembers() in D:\Data\vss\OTA2\OTASolution\DAL\EntityBaseClasses\AppParamEntityBase.vb:line 454
            at Fluor.OTA.DAL.EntityClasses.AppParamEntityBase.InitClassEmpty(IValidator validatorToUse) in D:\Data\vss\OTA2\OTASolution\DAL\EntityBaseClasses\AppParamEntityBase.vb:line 386
            at Fluor.OTA.DAL.EntityClasses.AppParamEntityBase..ctor() in D:\Data\vss\OTA2\OTASolution\DAL\EntityBaseClasses\AppParamEntityBase.vb:line 77
            at Fluor.OTA.DAL.EntityClasses.AppParamEntity..ctor() in D:\Data\vss\OTA2\OTASolution\DAL\EntityClasses\AppParamEntity.vb:line 44
            at Fluor.OTA.DAL.FactoryClasses.AppParamEntityFactory.Create() in D:\Data\vss\OTA2\OTASolution\DAL\FactoryClasses\EntityFactories.vb:line 142
            at Fluor.OTA.DAL.FactoryClasses.AppParamEntityFactory.Create(IEntityFields fields) in D:\Data\vss\OTA2\OTASolution\DAL\FactoryClasses\EntityFactories.vb:line 155
            at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.CreateEntityInstanceFromReaderRow(IEntityFields fieldsUsedForQuery, IFieldPersistenceInfo[] fieldPersistenceInfos, Dictionary`2 hierarchyFieldAliasesToOrdinals, List`1 fieldIndexToOrdinal, Dictionary`2 entityFieldStartIndexesPerEntity, Boolean hasExcludedFields, Object[] valuesOfRow, IEntityFactory& entityFactoryToUse)
            at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteMultiRowRetrievalQuery(IRetrievalQuery queryToExecute, ITransaction containingTransaction, IEntityCollection collectionToFill, Boolean allowDuplicates, IEntityFields fieldsUsedForQuery, IFieldPersistenceInfo[] fieldPersistenceInfos)
            at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformGetMultiAction(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
            at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicate selectFilter, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
            at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, IPrefetchPath prefetchPathToUse, ExcludeIncludeFieldsList excludedIncludedFields, Int32 pageNumber, Int32 pageSize)
            at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase`1.GetMulti(IPredicate selectFilter)
            at ApplicationParametersSingleton.Refresh() in D:\Data\vss\OTA2\OTASolution\DAL\Additional Classes\ApplicationParametersSingleton.vb:line 104
            at ApplicationParametersSingleton..ctor() in D:\Data\vss\OTA2\OTASolution\DAL\Additional Classes\ApplicationParametersSingleton.vb:line 27
            at ApplicationParametersSingleton..cctor() in D:\Data\vss\OTA2\OTASolution\DAL\Additional Classes\ApplicationParametersSingleton.vb:line 23
       InnerException: System.MethodAccessException
            Message="SD.LLBLGen.Pro.ORMSupportClasses.TypeDiscoverer..ctor()"
            Source="mscorlib"
            StackTrace:
                 at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
                 at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
                 at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
                 at System.Activator.CreateInstance(Type type, Boolean nonPublic)
                 at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
                 at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
                 at System.Activator.CreateInstance(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo, StackCrawlMark& stackMark)
                 at System.Activator.CreateInstance(String assemblyName, String typeName)
                 at System.AppDomain.CreateInstance(String assemblyName, String typeName)
                 at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
                 at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName)
                 at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider.Init()
                 at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProvider..ctor()
                 at SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionInfoProviderSingleton..cctor()
            InnerException: System.Security.SecurityException
                 GrantedSet="<PermissionSet class="System.Security.PermissionSet" version="1"> <IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Access="Open"/> <IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Allowed="ApplicationIsolationByUser" UserQuota="512000"/> <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="Execution"/> <IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Window="SafeTopLevelWindows" Clipboard="OwnClipboard"/> <IPermission class="System.Security.Permissions.SiteIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Site="tempuri.org"/> <IPermission class="System.Security.Permissions.StrongNameIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" PublicKeyBlob="0000000000000000" Name="OTASolution.application" AssemblyVersion="1.0.0.6"/> <IPermission class="System.Security.Permissions.UrlIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Url="http://tempuri.org/OTASolution.application"/> <IPermission class="System.Security.Permissions.ZoneIdentityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Zone="Internet"/> <IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" version="1" Level="SafePrinting"/> <IPermission class="System.Security.Permissions.MediaPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" version="1" Audio="SafeAudio" Video="SafeVideo" Image="SafeImage"/> <IPermission class="System.Security.Permissions.WebBrowserPermission, WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" version="1" Level="Safe"/> <IPermission class="System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1"> <ConnectAccess> <URI uri="(http|https)://tempuri\.org/.*"/> </ConnectAccess> </IPermission> </PermissionSet> "
                 Message="Request failed."
                 PermissionState="<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true"/> "
                 RefusedSet=""
                 Source="mscorlib"
                 Url=""
                 StackTrace:
                      at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
                      at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
                      at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
                      at System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh)
                      at System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandle rmh)
                      at System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
                      at System.Threading.CompressedStack.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet)
                      at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext)
                      at System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant)
                 InnerException: 

like2175
User
Posts: 83
Joined: 27-Mar-2006
# Posted on: 04-Jun-2009 16:45:10   

smile OK. Got it! I moved my Auditing.vb to a new project which compiled up to AuditingAssembly.dll.

To app.config I added:


<configSections>
             <section name="dependencyInjectionInformation" type="SD.LLBLGen.Pro.ORMSupportClasses.DependencyInjectionSectionHandler, SD.LLBLGen.Pro.ORMSupportClasses.NET20, Version=2.6.0.0, Culture=neutral, PublicKeyToken=ca73b74ba4e3ff27"/>
    </configSections>

and


    <dependencyInjectionInformation>
        <additionalAssemblies>
            <assembly filename="AuditingAssembly.dll"/>
         </additionalAssemblies>
    </dependencyInjectionInformation>


Then the top of my Auditor class looks like

''' <summary>Auditor class which is usable on all entities in a project.</summary>
<DependencyInjectionInfo(GetType(IEntity), "AuditorToUse"), _
Serializable()> _
Public Class OTAAuditor
  Inherits AuditorBase

A gotcha for anyone else just strating out with this: Be careful not to audit the updates to your AuditEntities or your code can disappear up its own ....

I used If entity.GetType to restrict auditing to the entity I was interested in.


 Public Overrides Sub AuditDirectUpdateOfEntities(ByVal entity As SD.LLBLGen.Pro.ORMSupportClasses.IEntityCore, ByVal filter As SD.LLBLGen.Pro.ORMSupportClasses.IPredicate, ByVal relations As SD.LLBLGen.Pro.ORMSupportClasses.IRelationCollection, ByVal numberOfEntitiesUpdated As Integer)


    ' Only interested in LocationId changing in Resource Entities... but could hook in here to audit anything else.
    ' This audits UpdateMulti's. 
    If entity.GetType Is GetType(ResourceEntity) Then

there may be neater ways...

thanks to all that helped. Graham

This is for self-servicing and llblgenPro v2.6.