Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Reflection.RuntimeModule.GetTypes() error with ODP.Net and C#

I wrote a fairly complex C# application which accesses an oracle database via ODP.Net. I developed the application on a windows XP machine (32-bit) where I installed ODAC (32-bit). The application runs without a glitch on my development PC but throws an exception on the server (windows server 2003 x64 service pack 2).

I installed the runtime for .Net framework 4.0 (dotNetFx40_Full_x86_x64.exe) on the server, as well as ODAC -- I first tried with Release 4 (11.2.0.3.0) for Windows x64 and then with ODAC 11.2 Release 4 (11.2.0.3.0) with Oracle Developer Tools for Visual Studio.

None of the worked. The 32-bit version got a bit further. The first time I call a LINQ statement on the database I get the following message.

   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at System.Reflection.Assembly.GetTypes()
   at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.LoadTypesFromAssembly()
   at System.Data.Metadata.Edm.ObjectItemAssemblyLoader.Load()
   at System.Data.Metadata.Edm.ObjectItemAttributeAssemblyLoader.Load()
   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, ObjectItemLoadingSessionData loadingData)
   at System.Data.Metadata.Edm.AssemblyCache.LoadAssembly(Assembly assembly, Boolean loadReferencedAssemblies, KnownAssembliesSet knownAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage, Object& loaderCookie, Dictionary`2& typesInLoading, List`1& errors)
   at System.Data.Metadata.Edm.ObjectItemCollection.LoadAssemblyFromCache(ObjectItemCollection objectItemCollection, Assembly assembly, Boolean loadReferencedAssemblies, EdmItemCollection edmItemCollection, Action`1 logLoadMessage)
   at System.Data.Metadata.Edm.ObjectItemCollection.ImplicitLoadAssemblyForType(Type type, EdmItemCollection edmItemCollection)
   at System.Data.Metadata.Edm.MetadataWorkspace.ImplicitLoadAssemblyForType(Type type, Assembly callingAssembly)
   at System.Data.Objects.ObjectContext.GetTypeUsage(Type entityCLRType)
   at System.Data.Objects.ObjectContext.GetEntitySetForNameAndType(String entitySetName, Type entityCLRType, String exceptionParameterName)
   at System.Data.Objects.ObjectContext.CreateObjectSet[TEntity](String entitySetName)
   at MyProgram.Data.DT.DTContext3.get_MYTABLE()

The 64-bit version tells me I have no Oracle.Access support, which is the same as the original error message I got when I first tried to run the application withouth ODAC on the server.

Can any of you help me on that? I've seen some entries discussing similar problems and the only convincing reply I saw was building the executable with Copy Local set to TRUE for all references and, but even that failed. I still get the same error message.

like image 760
edd Avatar asked Nov 03 '22 23:11

edd


1 Answers

I just found the answer myself. This piece of code, an entry by bgripka which I found in a discussion about this issue, gave me the answer. There was a reference to a missing library (which wasn't needed at all).

    catch (ReflectionTypeLoadException ex)
    {
        StringBuilder sb = new StringBuilder();
        foreach (Exception exSub in ex.LoaderExceptions)
        {
            sb.AppendLine(exSub.Message);
            if (exSub is FileNotFoundException)
            {
                FileNotFoundException exFileNotFound = exSub as FileNotFoundException;
                if (!string.IsNullOrEmpty(exFileNotFound.FusionLog))
                {
                    sb.AppendLine("Fusion Log:");
                    sb.AppendLine(exFileNotFound.FusionLog);
                }
            }
            sb.AppendLine();
        }
        string errorMessage = sb.ToString();
        log.Fatal(errorMessage);
    }
like image 181
edd Avatar answered Nov 12 '22 19:11

edd