Post

1 follower Follow
0
Avatar

Error on logging into Saas using Mocker with OOB Silverlight

Using the recommended code for an OOB Silverlight app from the Apprenda documentation like this:

            if (App.Current.IsRunningOutOfBrowser)

            {

                string userName = "Dwight Smith";

                string passWord = "whidbey220";

                // Initialize Apprenda

                Credentials creds = new Credentials(userName, passWord);

                try

                {

                    SessionContext.Instance.Initialize(result =>

                    {

                        if (result.IsError)

                        {

                            MessageBox.Show("Login failed.", "Login Error", MessageBoxButton.OK);

                        }

                        else

                        {

                            InitializeComponent();

                            ComboCulture.SelectedIndex = Singleton.StatusVM.SelectedCultureIndex;

                            LoadData();

                        }

                    }, creds);

                }

                catch (Exception ex)

                {

                    Utils.WriteLine(ex.Message);

                }

            }

I receive the following error:

            {System.TypeInitializationException: The type initializer for 'SingletonHolder`1' threw an exception. ---> System.Exception: An error occurred creating an Auto Wired instance. The class 'Apprenda.SaaSGrid.SessionContext-Default' was in fact found, but an error occurred while constructing it. See inner exception for details. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Apprenda.SaaSGrid.SessionContext' threw an exception. ---> Apprenda.Utility.NoSuitableWireException: Could not find a compatible type for instance 'Apprenda.Execution.ILogicalThreadStorage-Default' of type 'Apprenda.Execution.ILogicalThreadStorage'. This is not due to exceptions during loading, but instead is the result of an exhaustive probe across all loaders, which yielded nothing. Check the 'LoaderMessages' property of this exception for information posted by individual loaders.

Loader messages:

 Apprenda.Utility.NameSignedWireLoader1[[Apprenda.Execution.ILogicalThreadStorage, Apprenda.Utils.Silverlight, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]
 Apprenda.Utility.AutoWiredDomainBasedLoader
1[[Apprenda.Execution.ILogicalThreadStorage, Apprenda.Utils.Silverlight, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]

 Apprenda.Utility.DefinedDefaultWireLoader`1[[Apprenda.Execution.ILogicalThreadStorage, Apprenda.Utils.Silverlight, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]

   at Apprenda.Utility.Factory1.<>c\_\_DisplayClassf.<GetInstanceHelper>b\_\_c()
   at Apprenda.Threading.MonitorCollection
1.MonitorSection.Lock(LockableSection section, TimeSpan timespan)

   at Apprenda.Threading.MonitorCollection1.MonitorSection.Lock(LockableSection section)
   at Apprenda.Utility.Factory
1.GetInstanceHelper(String name, Assembly callingAssembly, Object[] arguments)

   at Apprenda.Utility.Factory1.GetInstance(Object[] arguments)
   at Apprenda.SaaSGrid.SessionContext..cctor()
   --- End of inner exception stack trace ---
   at Apprenda.SaaSGrid.SessionContext..ctor()
   at Apprenda.SaaSGrid.API.Local.HostBasedSessionContext..ctor()
   --- End of inner exception stack trace ---
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance(Type type, Boolean nonPublic)
   at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
   at System.Activator.CreateInstance(Type type, Object[] args)
   at Apprenda.Utility.AutoWiredDomainBasedLoader
1.PerformLoaderWork(String name, Object[] arguments)

   at Apprenda.Utility.AutoWiredDomainBasedLoader1.LoadInstance(String name, Assembly callingAssembly, Object[] arguments)
   --- End of inner exception stack trace ---
   at Apprenda.Utility.AutoWiredDomainBasedLoader
1.LoadInstance(String name, Assembly callingAssembly, Object[] arguments)

   at Apprenda.Utility.Factory1.<>c\_\_DisplayClassf.<GetInstanceHelper>b\_\_c()
   at Apprenda.Threading.MonitorCollection
1.MonitorSection.Lock(LockableSection section, TimeSpan timespan)

   at Apprenda.Threading.MonitorCollection1.MonitorSection.Lock(LockableSection section)
   at Apprenda.Utility.Factory
1.GetInstanceHelper(String name, Assembly callingAssembly, Object[] arguments)

   at Apprenda.Utility.Factory1.GetInstance(Object[] arguments)
   at Apprenda.Utility.LateBoundSingleton
1.SingletonHolder1..cctor()
   --- End of inner exception stack trace ---
   at Apprenda.Utility.LateBoundSingleton
1.get_Instance()

   at InnReservas.MainPage..ctor()}

Any help?

Dwight Smith

Please sign in to leave a comment.

15 comments

0
Avatar

Hi Dwight,

It seems that you are referencing the Local API rather than the Silverlight one.

Can you try referencing the Silverlight dll and let me know if the error persists?

Thanks,

Bernie

Bernie Herdan 0 votes
0
Avatar

In my client References, I have references to Apprenda.Utils.Silverlight, SaasGrid.API.Silverlight, and SaasGrid.API.SIlverlight.Local.

In the code i have the using statement "using Apprenda.SaasGrid".  

Where else should I check for the Local API reference?

 

Thanks much.

Dwight Smith 0 votes
0
Avatar

Hi Dwight,

Could you tell me more information about what Silverlight version you are running, as well as any additional information?

Thanks,

Bernie

Bernie Herdan 0 votes
0
Avatar

Silverlight 5 SDK and Toolkit, Out of Browser application

Using WCF Ria Services V1.0, SP2, and WCF Ria Services Toolkit (September 2011)

.NET Framework 4  (C#)

MSSQL  Server 2008 R2

Other Libraries used:     EntityGraph.Sliverlight, IRPortableResourceLibrary, RiaServicesContrib.EntityTools, Wintellect.Threading.Silverlight

 

 

 

Dwight Smith 0 votes
0
Avatar

I was NOT referencing Apprenda.Execution.CallContextStorage.  When I try and add the reference, VS does not add it even though I click "Add" in the References dialog..

Dwight Smith 0 votes
0
Avatar

The problem with referencing Apprenda.Execution.CallContextStrorage is probably because the dll is not Silverlight compatible. Is there a Silverlight version?

Dwight Smith 0 votes
0
Avatar

Hi Dwight,

I had encountered a similar problem while developing a WCF service and solved it by referencing the Apprenda.Execution.CallContextStorage dll.

As soon as I realized that it was not compatible with Silverlight I removed it from the post to avoid confusion. I apologize for not clarifying that earlier.

I am attaching a sample application using Silverlight. Hopefully this will clarify your doubts.

Please let me know if that doesn't help.

Bernie

Bernie Herdan 0 votes
0
Avatar

Bernie,

 

The sample you sent is built with Silverlight 4.  Do we need to revert back to Silverlight 4 in order to work with Apprenda?

 

Thanks

Dwight

Dwight Smith 0 votes
0
Avatar

Hi Dwight,

It should work without having to revert it. I'm going to create a sample and get back to you as soon as its ready.

Thanks,

Bernie

Bernie Herdan 0 votes
0
Avatar

Hi Dwight,

The API Supports Silverlight 5. Make sure you install both Silverlight 5 Tools and the Silverlight 5 Developer Runtime.

Are you running your application locally or on Apprenda when you are getting that error?

Thanks,

Bernie

Bernie Herdan 0 votes
0
Avatar

As I said in the opening subject to this thread, I am trying to use Mocker (the local mock environment) to develop the Apprenda part of the applicaiton.  So, I am trying to run it locally.  However, I do have Apprenda Express installed on the same machine.  Is that the problem?  Can you run the mock environment on a machine with Apprenda Express installed?

I was also following the suggested code for OOB to start up a SessionContext.Instance.  That is what gave me the error in the opening message of this thread. 

I have installed the Silverlight 5 Tools, the Silverlight 5 SDK and the Silverlight 5 Developer  Runtime.  The Silverlight Developer Runtime is the x64 version. 

Dwight Smith 0 votes
0
Avatar

BTW, what should be in the Web.config of the web project to init the local environment?  I assume it should be as in the documentation but referencing the SaasGrid.API.Sliverlight.Local instead of SaasGrid.API.Local.  Is this correct?  Should it still reference "ContextInitModule" and "ContextDisposeModule" ?

Dwight Smith 0 votes
0
Avatar

Please disregard the questions about Web.config above...I just copied what was in the Web.config of the Taskr example you sent me. 

Dwight Smith 0 votes
0
Avatar

Hi Dwight,

Running Mocker with Apprenda Express should not be a problem.

In terms of the error message, SessionContext should not throw an error if you are referencing the right DLL's. Check the Taskr Sample I sent you and make sure that you are referencing all of the Apprenda and SaaSGrid dlls in your project.

It would be extremely helpful if you could send me your entire stack trace error so I can perform further tests.

Thanks,

Bernie

Bernie Herdan 0 votes
0
Avatar

Hey Bernie,

I got things working!   Thanks a bunch.  Went through all the references and made sure I matched the Silverlight sample.  As it turns out I didn't need the Web.config changes. 

 

Thanks again,

Dwight

Dwight Smith 0 votes