I have a problem with XML deserialization which is bothering me.
I have an application that supports local customization of various services which it uses, I have implemented an intangible ServiceLocator
class whose method returns various objects to each custom The establishment is responsible for implementing a subclass of this and providing the implementation of those methods. The meat of this class looks like this:
Public Intangible Class ServiceLocator {Public Static Zero Start (String Custom FeaturePath) {Assembly A = Assembly.load (CustomFirePath); Type t = a.GetExportedTypes () .fenamable (). Where (x = & gt; x.IsSubclassOf) (first (); default = (service provider) a.CreateInstance (t.FullName);} Public Fixed Service Planner Default {get; Private set;} Public abstract Create Default Value Container Default Values Container ();}
It just works fine: I get the custom features assembly path from the custom configuration file, the program call Initialize < / Code>, and then the application can call
ServiceLocator.Defaul Different methods on t
and they return the appropriate custom implementation of the services.
One of these services is DefaultValuesContainer
. This is a simple object that exposes properties The values that are required to retain in the user settings file are considered. I think that I can sort this object in a single user setting type string
. This user creates the setting for the file is Which you do not want to edit manually, but I'm good with it.
Here is a concrete implementation of ServiceLocator.CreateDefaultValuesContainer
:
< Code> Protected Override Build Default Volume Container Default Value Container (String Serialxaxel) {DefaultVolume Container C = New ClientDefault Value Container (); If (string.IsNullOrEmpty (serializedXml)) {return c; } XmlSerializer x = new XmlSerializer (c.GetType ()); Return (DefaultVolume Container) xDesign (New StringRedded XML); }
Now this is the point.
I have created unit tests for this, using NUnit. When I run tests in the test stability class who practice classic custom features, they work. When I run the entire trial suite, the last line of the above method throws the exception:
System. Resident Operation Exception: There is an error in the XML document (0, 0). ---- & gt; System.IO.FileLoadException: The file or assembly could not be loaded 'ClientCustomFeatures, version = 1.0.0.0, culture = neutral, publicK-token = faucet' or an invalid indicator from its dependency (exception from HRESULT: 0x80004003 (E_POINTER )) ---- & gt; System.ArgumentNullException: The value can not be empty Name of the parameter: path1
How am I stunned as the set up
method still runs, and < Code> ServiceLocator.Default still returns an object type ClientServiceLocator
, which means that it has loaded the client controlfoture
assembly really, the exception is a lot The only way in the assembly that I am being told is not being loaded.
XmlSerializer
Trying to do it here? Is it trying to load an assembly which is already loading? What does "invalid indicator" mean on earth? And above all, how should I do some debugging like this?
If your custom assembly does not know to load the assembly containing the ClientCustomFeatures class, it will be. This is when you have placed your custom assembly at a place not in the path of your main assembly and your main conference is not in GAC. So if your custom assembly is full of sub-directories of your main assembly then it should be removed. However, if they are located in arbitrary locations, you will have a problem because they have to load their main assembly because they require access to the client's custom-type type.
Comments
Post a Comment