Exception when setting option for DependencyInjection in App.config

Posts   
 
   
 
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 22-May-2017 07:59:09   

On the latest 5.2 version, trying to add concurrency to Timestamp fields... Dotnet v4.6.2, working with LLBLGen framework and SQL Server.

So I add the bottom code to my DatabaseGeneric project, which has worked in the past, then I add to App.config


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

Executing the application gives the following error:


System.IO.FileLoadException: 'Could not load file or assembly 'Anonymously Hosted DynamicMethods Assembly, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)'

This is raised by one of my Entity classes, in the call


        /// <summary> Initializes the class members</summary>
        private void InitClassMembers()
        {
            PerformDependencyInjection();  <======
            
            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END
            OnInitClassMembersComplete();
        }

Any suggestions?

Cheers, Jason


using SD.LLBLGen.Pro.ORMSupportClasses;

namespace SMS.DB
{
    [DependencyInjectionInfo(typeof(IEntity2), "ConcurrencyPredicateFactoryToUse",
        ContextType = DependencyInjectionContextType.NewInstancePerTarget)]
    public class TimestampConcurrency : IConcurrencyPredicateFactory
    {
        public IPredicateExpression CreatePredicate(ConcurrencyPredicateType predicateTypeToCreate,
            object containingEntity)
        {
            IPredicateExpression toReturn = new PredicateExpression();
            IEntity2 entity = (IEntity2)containingEntity;

            var tsfield = entity.Fields["Timestamp"];

            if (tsfield != null)
            {
                switch (predicateTypeToCreate)
                {
                    case ConcurrencyPredicateType.Delete:
                        toReturn.Add((EntityField2)tsfield == entity.Fields[tsfield.FieldIndex].DbValue);
                        break;
                    case ConcurrencyPredicateType.Save: // only for updates

                        toReturn.Add((EntityField2)tsfield == entity.Fields[tsfield.FieldIndex].DbValue);
                        break;
                }
            }
            return toReturn;
        }
    }
}

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 22-May-2017 09:39:18   

The exception says " The located assembly's manifest definition does not match the assembly reference. " which is an error reported by .NET (fusion, its assembly loader). If you specify 'autoDependencyInjectionDiscovery', it will load all assemblies in the application's folder to find types marked for dependency injection. One of them is not loadable (the one in the error message). Not sure why though I don't know what assembly that is (the one in the error message). What assembly is that and is it correct that it is there? If so, you could try to specify the DI types directly into the appConfig file and not specify autoDependencyInjectionDiscovery, so it will not traverse all assemblies but just the ones you specify.

Frans Bouma | Lead developer LLBLGen Pro
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 22-May-2017 12:21:16   

Otis wrote:

What assembly is that and is it correct that it is there? If so, you could try to specify the DI types directly into the appConfig file and not specify autoDependencyInjectionDiscovery, so it will not traverse all assemblies but just the ones you specify.

It reports it as an Anonymous dynamic assembly, so I have no idea which it is. My guess is that it's related to ClearScriptV8, which is the Javascript engine used in Chrome, as that's the only significant nuget package I have included in the solution. For now I've added the concurrency factory in the Entity itself, as this is the only place it's needed for this project, but it is a bit of a pain.

Thanks Frans.

Oh, and I had to create this new user to get into the forums because the system doesn't send me my password when I request a reset. My Username is usually jsobell. I guess I should have stayed at home today simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 22-May-2017 19:20:56   

You could use fuslogvw.exe, it's in the .NET SDK, you have to run it as administrator (and your application too), and it will log the assembly load issues, and which assembly/dll it is. It's not the most usable tool on the planet so it might be at first you won't see anything logged. Be sure to use the one for the .net version you're using, so if you're using .net 4.x, be sure to use the one in the .net 4.x sdk. So first start fuslogvw.exe, then your app and the UI of fuslogvw.exe should then log some entries, which you can examine and it will show what assemblies it tried to load and where.

For the user: do you want us to reset the password of the other account? the password emails are send but they're often caught by spam filters...

Frans Bouma | Lead developer LLBLGen Pro
JSobell
User
Posts: 145
Joined: 07-Jan-2006
# Posted on: 23-May-2017 08:02:05   

Otis wrote:

You could use fuslogvw.exe...

For the user: do you want us to reset the password of the other account? the password emails are send but they're often caught by spam filters...

I'll try and get around to checking it when I get a free hour or three to figure it all out again simple_smile

Re the user, I already requested a password reset, and although it reporting sending the password it never arrived (and yes, I checked the spam folders). The address is redirected to my Google Apps email address (which is what I'm using now) but it doesn't usually have any issues that I'm aware of. Please fell free to assign a password and email it to me directly if the system allows that. I don't really want multiple accounts on the forum, particularly when they are now different to my client login email simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 23-May-2017 10:44:49   

I've reset the password of the original account and have mailed you the new password to the email address associated with it

I'll also set the messages of this new account to the id of the original account so you can find them back with the original account after you've logged in.

Please let me know if you didn't receive that email.

Frans Bouma | Lead developer LLBLGen Pro