TypeIntialization exception when called from BizTalk


i  typeintialization exception when call biztalk

 

exception while initializing settings  - system.nullreferenceexception: object reference not set instance of object.

  

 

but when call winform (as test) it works ok. have un-gaced , re-gaced eai.utils component many times. registry keys exists (it works .net winform test)!!

 

this code:

 

      private static void initialize()

        {

            cache = new dictionary<string, object>();

 

            //- double-checked locking

            if (configuration == null)

            {

                lock (synclock)

                {

                    if (configuration == null)

                    {

                        registrykey regkey = null;

 

                        try

                        {

                            regkey = registry.localmachine.opensubkey(@"software\somecompany\eai");

                            configurationfile = path.combine(

                                (string)regkey.getvalue("configdir"),

                                (string)regkey.getvalue("configfile"));

 

                            execonfigurationfilemap filemap = new execonfigurationfilemap();

                            filemap.execonfigfilename = configurationfile;

                            configuration = configurationmanager.openmappedexeconfiguration(filemap, configurationuserlevel.none);

                            configurationsource = new fileconfigurationsource(configurationfile);

 

                            //- store configpath in settings

                            configuration.appsettings.settings.add(

                                new keyvalueconfigurationelement("configdir", (string)regkey.getvalue("configdir")));

                        }

                        catch (exception ex)

                        {

                            string errmsg = "exception while initializing settings:" + ex.tostring();                            eventlog.writeentry("eai", errmsg + environment.newline + ex.stacktrace.tostring(), eventlogentrytype.error);

                           

                            throw;

                        }

                        finally

                        {

                            if (regkey != null) regkey.close();

                        }

                    }

                }

            }     

 

this wrapper around microsoft.practices.enterpriselibrary.configuration

any ideas wrong? stumped!

 

it looks kind of permission issue

 

the regkey value not initializing properly.

regkey = registry.localmachine.opensubkey(@"software\somecompany\eai");

 

use "run as" command , run winforms application using credentials under biztalk host instance nt service running, , see if getting more useful error information.

 

regards,
saravana kumar
http://www.biztalk247.com/v1/
http://www.digitaldeposit.net/blog
[please mark response "answer" if solves problem.]



BizTalk Server  >  BizTalk Server General



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

BizTalk Server 2013 Azure VM Log Shipping and HA for hosts

How to send non-standard Content-Type header ?