Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7841949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:12:33+00:00 2026-06-02T16:12:33+00:00

We have a job server the processes jobs submitted from websites. The website’s assemblies

  • 0

We have a job server the processes jobs submitted from websites. The website’s assemblies are packaged up and submitted to the job server as part of the job (including all the satellite resource assemblies).

These assemblies are loaded via: Assembly.Load( byte[] ) before job processing starts.

During job processing, we get to a point where we want to snapshot a resource string (i.e. a validation message). Note, that simply storing the resource key isn’t an option, because the validation rule/message may change over time and if they come back to view previously processed jobs/messages, I don’t want the ‘latest’ resource string displayed. I need the value at the time of job processing displayed. And I need a snapshot of each supported culture’s message so that I can display messages in the appropriate culture that the website thread is running on.

To try and retrieve the messages, the website assembly specifies which locales are supported, so on the job server, I do something like this to create the website assembly’s ResourceManager:

var resourceType = Type.GetType( "BTR.Websites.MadHatter.Clients.ABCCorp.Resources.ClientStrings" );
var rm = resourceType != null ? new ResourceManager( resourceType ) : null;

This works fine an I get a ResourceManager, however, given an XElement validationRule and a string[] locales, the following code ‘does not work’:

validationRule.Add( 
    from l in locales
    let message = rm.GetString( p.Value.ToString(), new CultureInfo( l ) )
    select new XAttribute( string.Format( "Message.{0}", l ), message ) );

Essentially, no matter what CultureInfo I pass in, I get the default (en-US) culture’s message.

AppDomain.CurrentDomain.GetAssemblies() shows both the website assembly and satellite assembly loaded:

{ABCCorp.ServiceModel, Version=6.0.4497.18334, Culture=neutral, PublicKeyToken=null} System.Reflection.Assembly {System.Reflection.RuntimeAssembly}
{ABCCorp.ServiceModel.resources, Version=6.0.4497.18334, Culture=fr-FR, PublicKeyToken=null} System.Reflection.Assembly {System.Reflection.RuntimeAssembly}

But if I try the following in watch window (same as code above), I get the en-US version:

rm.GetString( “ResourceKey”, new CultureInfo( “fr-FR” ) )

Lastly, presummably we are all familiar with LINQPad 🙂 The following script ‘works’. I do not have any references to ABCCorp’s ServiceModel.dll or satellite dll.

Assembly.LoadFile( @"C:\BTR\Source\ABCCorp.ServiceModel.dll" );
Assembly.LoadFile( @"C:\BTR\Source\fr-FR\ABCCorp.ServiceModel.resources.dll" );
AppDomain.CurrentDomain.GetAssemblies().Dump();
var resourceType = Type.GetType( "BTR.Websites.MadHatter.Clients.ABCCorp.Resources.ClientStrings, ABCCorp.ServiceModel" ).Dump();
var rm = resourceType != null ? new ResourceManager( resourceType ) : null;
rm.GetString( "FlatMemberInformationBasicInformation_DateDeathProof", new CultureInfo( "fr-FR" ) ).Dump();

Any suggestions would be GREATLY appreciated.

UPDATE:
Based on suggestions from Joe, here is the code we ended up with. byte[] content is a zip file containing website assembly and all satellite resource assemblies if present.

private Assembly LoadPackagedAssembly( byte[] content )
{
    var loaded = new Dictionary<string, Assembly>();

    AppDomain.CurrentDomain.AssemblyResolve += delegate( object sender, ResolveEventArgs args )
    {
        return loaded.ContainsKey( args.Name )
            ? loaded[ args.Name ]
            : null;
    };

    Assembly mainAssembly = null;

    using ( var stream = new MemoryStream( content ) )
    {
        using ( var zip = new ZipInputStream( stream ) )
        {
            ZipEntry entry;

            while ( ( entry = zip.GetNextEntry() ) != null )
            {
                using ( var buffer = new MemoryStream() )
                {
                    Streams.CopyStream( zip, buffer );

                    var assembly = Assembly.Load( buffer.ToArray() );

                    loaded[ assembly.FullName ] = assembly;

                    if ( mainAssembly == null ) mainAssembly = assembly;
                }
            }
        }
    }

    return mainAssembly;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T16:12:34+00:00Added an answer on June 2, 2026 at 4:12 pm

    This sounds like an assembly resolution problem. With Load(byte[]) and LoadFile, you end up with no binding context. In short, either use LoadFrom, or handle the AppDomain’s AssemblyResolve event to deal with this.

    Note that LINQPad handles the AssemblyResolve event to smooth over problems caused by indirectly referencing the same DLL in different locations. A side-effect of this is that it fuses the binding contexts in scenarios where a binding would otherwise fail, making things work that might not otherwise.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Custom ThreadPool which Accepts Jobs from Client, Processes it and
Background We have worker processes that read jobs from a table in SqlServer then
I have a job on SQL Server 2005 running a ssis package. The package
We have a job management application running (Access) with the database in SQL Server
I have a java JAR file that is triggered by a SQL server job.
At my current job we have a CMS system that is .NET/SQL Server based.
I have added a new job in my hudson server which builds the project
Afternoon. I have several SQL Agent jobs running on an MS 2K8 BI server,
I have an automated job that pulls files that are uploaded to our servers
At my day job we have load balanced web servers which talk to load

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.