Support for .NET 3.5

Mar 19, 2009 at 5:04 AM
Edited Mar 19, 2009 at 5:06 AM
Excellent project!   I was a happy camper when I found this DI for Mobile Project and am impressed with it so far.   I did run into an issue trying to use it with .NET 3.5 and created a work-around/alternate solution - instead of deserializing the Config.XML (which doesn't work using the 3.5 assemblies) I used LINQ to XML taking advantage of the power of 3.5 extensions.

Blogged about on the following link:
http://www.global-webnet.net/blogengine/post/2009/03/18/Mobile-Framework-for-Mobile-50-with-a-Compact-(DI)-Container.aspx

Source code is provided on the above link with the prototype I created to integrate it into my framework; so far it only reads in the config.xml file.

I did encounter an error that I fixed with the following code - it may be related to the error that occurs when you click the TestDI sample button twice.

           /// <summary>
            /// Adds a Object Definition to the Registry
            /// </summary>
            /// <param name="context">name of the context</param>
            /// <param name="obj"></param>
            public void AddDefinition(string context, ObjectDefinition obj){
                try
                {
                    if (!_registry.ContainsKey(context))
                        _registry.Add(context, new Dictionary<string, ObjectDefinition>());
 
                    // BillKrat.2009.03.18 - crashes if the context already contains
                    // the key about to be added; this happens if multiple processes
                    // load the container.  Don't attempt to add key if it already exist
                    if (!_registry[context].ContainsKey(obj.Name))
                        // Original code follows - the above line added
                        _registry[context].Add(obj.Name, obj);
                }
                catch (ArgumentException ex)
                {
 
                    throw new Exception("", ex);
                }
            }
 


Coordinator
Mar 11, 2010 at 12:58 AM
Edited Mar 11, 2010 at 1:13 AM

Lol! thanks!!

One year later my replay. :)

I will fix it soon.

 

Thanks,

Mariano Vicario

 

Coordinator
Mar 11, 2010 at 1:17 AM

I just checked and is already fix in this release.

 

The code now in that method is:

 /// <summary>

            /// Adds a Object Definition to the Registry

            /// </summary>

            /// <param name="context">name of the context</param>

            /// <param name="obj"></param>

            public void AddDefinition(string context, ObjectDefinition obj){

                try

                {

                    if (!_registry.ContainsKey(context))

                        _registry.Add(context, new Dictionary<string, ObjectDefinition>());

                    if(!_registry[context].ContainsKey(obj.Name))

                        _registry[context].Add(obj.Name, obj);

                }

 

Thanks!

Mariano Vicario

 

if (!_registry.ContainsKey(context))
                        _registry.Add(context, new Dictionary<string, ObjectDefinition>());
                    if(!_registry[context].ContainsKey(obj.Name))
                        _registry[context].Add(obj.Name, obj);