Skip to content

Error log from ReflectHelper.TypeFromAssembly() on Linq query #2855

Closed
@cremor

Description

@cremor

Since I updated to version 5.3.9 my application logs this error the first time a specific Linq query is executed:

Could not load type mappedcust2_.IS_LEAD_CUSTOMER, mappedcust2_.CUST_ID.Customer.
System.IO.FileNotFoundException: Could not load file or assembly 'mappedcust2_.CUST_ID.Customer' or one of its dependencies. Das System kann die angegebene Datei nicht finden.
File name: 'mappedcust2_.CUST_ID.Customer'
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
   at System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at NHibernate.Util.ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName name, Boolean throwOnError)

=== Pre-bind state information ===
LOG: DisplayName = mappedcust2_.CUST_ID.Customer
 (Partial)
WRN: Partial binding information was supplied for an assembly:
WRN: Assembly Name: mappedcust2_.CUST_ID.Customer | Domain ID: 1
WRN: A partial bind occurs when only part of the assembly display name is provided.
WRN: This might result in the binder loading an incorrect assembly.
WRN: It is recommended to provide a fully specified textual identity for the assembly,
WRN: that consists of the simple name, version, culture, and public key token.
WRN: See whitepaper http://go.microsoft.com/fwlink/?LinkId=109270 for more information and common solutions to this issue.
LOG: Appbase = file:///C:/.../Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : NHibernate, Version=5.3.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\...\Debug\App.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: The same bind was seen before, and was failed with hr = 0x80070002.

I haven't yet reduced the query to a minimal reproducable sample, but the query is something like this:

public int GetCountOfChangeEntries(User user) {
   var customerQuery = session.Query<Project>()
      .Where(x =>
         !x.State.Completed &&
         x.User == user &&
         ((SpecificProject)x).Successor == null
      )
      .SelectMany(x => x.CustomerRelations)
      .Select(x => x.Customer);

   return session.Query<ChangeEntry>()
      .Count(x => customerQuery.Contains(x.Customer) && x.State == ChangeEntryState.Unhandled);
}

Maybe there are more queries that log that error, but I've only noticed it for this one until now.
The query seems to work fine even with the error.

The properties/columns mentioned in the error message (mappedcust2_.IS_LEAD_CUSTOMER, mappedcust2_.CUST_ID.Customer) are contained in a relation-component that is used via the CustomerRelations property in the query. It's mapped as a component collection on both sides (Customer and Project) and contains two references (one parent reference and one to the other entity) and a simple bool property (with the column name IS_LEAD_CUSTOMER).

When I downgrade to 5.3.8 the error doesn't happen any more. The Linq query produces the same SQL with both versions.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions