New Posts New Posts RSS Feed: OOB and dialogmanager
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

OOB and dialogmanager

 Post Reply Post Reply
Author
siko View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Mar-2012
Posts: 27
Post Options Post Options   Quote siko Quote  Post ReplyReply Direct Link To This Post Topic: OOB and dialogmanager
    Posted: 07-Jun-2012 at 5:38am
Hi,
 
We might like to offer the OOB functionality for our application, so we checked the checkbox and the startup project changes to be the sl project we enabled oob for.
 
Now all seems fine (and the sl client finds it server!)
 
If however I set the web project to be the startup project, the method ShowDialogAsync results in this exception:
 
Attempt by method 'Microsoft.Internal.ReflectionInvoke.SafeInvoke(System.Reflection.MethodInfo, System.Object, System.Object[])' to access method 'Cocktail.ShowDialogResult`1<System.__Canon>.set_WindowManager(Caliburn.Micro.IWindowManager)' failed.
 
Last time I tried to open a solution on another system I toggled the OOB checkbox and the error went away. This time it persists.
 
What can I do to fix this?
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 10:51am
I'm a bit confused. If you run the app OOB, the Silverlight app would be the start project not the web project. I haven't seen this issue. I've actually created a TempHire OOB demo for somebody a little while ago. Now, I probably didn't test all the paths, but so far I only found one issue with asynchronous bootstrapping that I haven't fixed yet.
 
Can you provide me with the exact steps to repro this. Debugging OOB is a little flaky in Visual Studio in my experience. Does this happen if you run the application outside of Visual Studio as well?
Back to Top
siko View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Mar-2012
Posts: 27
Post Options Post Options   Quote siko Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 2:26pm
I cannot provide the exact steps. Other than that a fine working asp.net web application running the website does not run the sl app correct (ie. the dialogmanager), once you enabled OOB at least once.
 
When the app (compiled for OOB) is requested via the web server, it runs as allways (inside the browser) until we want to display a dialog... it does not get displayed and the app does not report an error. We didnt handle the OOB feature in code, just flipped the switch to see things would still run.
 
Now setting it back to disabled (oob), the app still does not display the dialog and breaks in vs debugger with the error i posted before.
 
Would the stacktrace help?
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 2:41pm
I don't think the stackstrace will help. It makes no sense to me at the moment that you are getting this exception unless you modified the Cocktail source code. Here's why. MEF is failing for you to inject the WindowManager into ShowDialogResult. You are getting a MethodAccessException, right?
 
Now, to the best of my knowledge this only ever happens if the property or class isn't public in Silverlight. Silverlight's security model does not permit private reflection. The following is the property copied/pasted directly from the source code. As you can see the property is public.
 
        /// <summary>
        /// Internal use.
        /// </summary>
        [Import]
        public IWindowManager WindowManager { get; set; }

Are you using any third-party stuff that might interfere with reflection?
Back to Top
siko View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Mar-2012
Posts: 27
Post Options Post Options   Quote siko Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 10:10pm
If you call using an internal class for defining dialogbuttons third party stuff, then yes:
 
var searchToAddApplicant = _findToAddFactory.CreatePart();
            searchToAddApplicant.Start();
            //searchToAddApplicant.Parent = this;
            //_windowManager.ShowDialog(searchApplicant, this);
 
            //prepare async dialog operation
            DialogOperationResult<TaggedButtons> asyncOp;
            var findButton = new TaggedButtons("Find" /*todo: replace with translation lookup*/) { IdTag = "FIND" };
            var cancelButton = new TaggedButtons("Cancel" /*todo: replace with translation lookup*/) { IdTag = "" };
            yield return asyncOp = _dialogManager.ShowDialogAsync(
                searchToAddApplicant, new List<TaggedButtons>()
                                          {
                                              findButton,
                                              cancelButton
                                          }, "Find or Add Applicant");
//and ..
internal class TaggedButtons : DialogButton
        {
            private readonly object _value;
 
            public TaggedButtons(object value)
                : base(value)
            {
                _value = value;
            }
 
            public override string ToString()
            {
                return _value.ToString();
            }
 
            public string IdTag { getset; }
        }
 
 
Making the class public seems to solve the issue. But why didn't I run into this only until after I enabled/disabled OOB?
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 10:30pm
Rather strange how it manifested itself, but yes, that would be a problem. It probably kinda worked, because the base type (DialogButton) is public. Sorry, I don't have a better answer at this point. If you want to make your TaggedButtons class internal, you need to make your internals visible to Cocktail.  
 
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 07-Jun-2012 at 11:06pm
Also, is there a reason you are using DialogButton as the base class for your button type? DialogButton is a wrapper that the DialogManager puts around your object for binding purposes. Just noticed that I inadvertently made the constructor public. I will "fix" that for the next release, which will break your code.
Back to Top
siko View Drop Down
Newbie
Newbie
Avatar

Joined: 26-Mar-2012
Posts: 27
Post Options Post Options   Quote siko Quote  Post ReplyReply Direct Link To This Post Posted: 08-Jun-2012 at 6:15am
I had some other issues with this solution. Did some namespace changes and I had a clash between the theme and shell projects.
 
That out of the way and clear on the DialogButton class, all seems to work fine again.
 
Thanks for the great responses. I'm happy we went with DF for our project!
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down