BizTalk Server General - Weird when using Enterprise Library in pipeline component

This is Interesting: Free IT Magazines  
Home > Archive > BizTalk Server General > March 2006 > Weird when using Enterprise Library in pipeline component





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Weird when using Enterprise Library in pipeline component
twang090@gmail.com

2006-03-11, 2:47 am

I was trying to use configuration application block in my pipeline
component. First I didn't give it a strong name, my code fails with
'Cannot create type ... ...'. Then I sign it and GAC it, after
rebouncing BizTalk, this time I got a 'invalid cast' error. While I was
trying to trace in my code, I found that my code fails when I tries to
cast the object acquired by 'ConfigurationManager.GetConfiguration' to
my custom config class. Although, when I looked at debugger, the object
type is of my config class! That's weird.

This keeps me in pain the entire afternoon, anyone would like a help?
Have anyone managed to use EntLib in pipeline component?

Thanks

Tomas Restrepo \(MVP\)

2006-03-11, 7:47 am

>I was trying to use configuration application block in my pipeline
> component. First I didn't give it a strong name, my code fails with
> 'Cannot create type ... ...'. Then I sign it and GAC it, after
> rebouncing BizTalk, this time I got a 'invalid cast' error. While I was
> trying to trace in my code, I found that my code fails when I tries to
> cast the object acquired by 'ConfigurationManager.GetConfiguration' to
> my custom config class. Although, when I looked at debugger, the object
> type is of my config class! That's weird.
>
> This keeps me in pain the entire afternoon, anyone would like a help?
> Have anyone managed to use EntLib in pipeline component?


It sounds like it is loading the assembly containing the configuration from
a different place. The thing to remember here is that in BTS 2004 you have
to be careful with pipeline components because they are loaded from an
specific folder and not the GAC, so they do have a different loading
context, and that .NET considers to assemblies with the exact same name and
version loaded from two different locations to be different with
incompatible types. So check (maybe in the debugger) where the libraries are
getting loaded from.


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


Tommy

2006-03-11, 5:50 pm

You are right, Tomas. They do have the same full name but difference
locations, BizTalk loads the type from "pipeline components" directory while
configuration application block tries to load from GAC.

The above scenario happens when I GAC my pipeline component. However, if I
don't GAC it, when I tries to use ConfigurationManager.GetConfiguration, I
always got a 'Cannot create type ...' error.

Those being said, I am really frustrated now and am going to give up using
EntLib in pipeline component. Anyone has some work around?

"Tomas Restrepo (MVP)" wrote:

>
> It sounds like it is loading the assembly containing the configuration from
> a different place. The thing to remember here is that in BTS 2004 you have
> to be careful with pipeline components because they are loaded from an
> specific folder and not the GAC, so they do have a different loading
> context, and that .NET considers to assemblies with the exact same name and
> version loaded from two different locations to be different with
> incompatible types. So check (maybe in the debugger) where the libraries are
> getting loaded from.
>
>
> --
> Tomas Restrepo
> tomasr@mvps.org
> http://www.winterdom.com/
>
>
>

Tomas Restrepo \(MVP\)

2006-03-11, 5:50 pm

Hi Tommy,

> You are right, Tomas. They do have the same full name but difference
> locations, BizTalk loads the type from "pipeline components" directory
> while
> configuration application block tries to load from GAC.
>
> The above scenario happens when I GAC my pipeline component. However, if I
> don't GAC it, when I tries to use ConfigurationManager.GetConfiguration, I
> always got a 'Cannot create type ...' error.
>
> Those being said, I am really frustrated now and am going to give up using
> EntLib in pipeline component. Anyone has some work around?


Not a very good solution, but you could compile a custom version of the
EntLib and deploy it just in the Pipeline Components folder and see if that
works.

This is one of the primary reasons, I believe, why for BTS2006 it is now
recommended that you deploy your pipeline components to the GAC, though you
still need to put them in your Pipeline Components folder during
development.


--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/


twang090@gmail.com

2006-03-11, 8:46 pm

Thanks a lot for the help, Tomas. I think that I found a work around.
Prevoiusly, my configuration class is in my pipeline component dll, for
now, I created a new project and put my config class into it. I then
GAC it. After all the work of recompile and rebounce BizTalk, I finally
managed to use the configuration block to read my configurations.

Cheers!

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com