Using types from System.Windows.Forms as arguments

Latest post 06-19-2007 11:03 AM by Melody. 1 replies.
  • 06-19-2007 5:10 AM

    Using types from System.Windows.Forms as arguments

    I expect to be missing something obvious, but when I add a method to my API that accepts an argument of type System.Windows.Forms.Form (or other types from that namespace, and I've also tried System.Drawing.Graphics, which works well in the ShapeAddAdvancedCSharp sample without luck), I get a runtime error in proxy.cs, where a KeyNotFoundException is being thrown.

    Passing other types (my own from the API, or System.String and so forth) works fine, which is why I'm thinking that I've messed things up.

    Example of proxy code that causes the exception to be thrown:
    this.@__vstaCacheTest33 = this.remoteType.GetMethod("Test3", (((global::System.Reflection.BindingFlags.Public | global::System.Reflection.BindingFlags.InvokeMethod)

    | global::System.Reflection.BindingFlags.Instance)

    | global::System.Reflection.BindingFlags.Default), null, new global::System.Type[] {

    typeof(global::System.Drawing.Graphics)}, null);


    Thanks in advance,
    Bjorn Karlsson

  • 06-19-2007 11:03 AM In reply to

    • Melody
    • Top 10 Contributor
    • Joined on 04-26-2007
    • Syracuse, NY
    • Posts 245

    Re: Using types from System.Windows.Forms as arguments

    Bjorn,

                    System.Windows.Forms.Form is not serializable- therefore cannot be used in the proxy layer.  System.Drawing.Graphics; however, should be okay, as you saw in the ShapeAppAdvancedCSharp sample.  More basic types like System.String will also work. 

    The KeyNotFoundException is usually indicative of a mismatch- possibly between a type in your proxy and the TypeInfrastructureManager.  The code you included looks fine to me- pretty much an exact match to the Proxy.cs line 323 in ShapeAppAdvancedCSharp.  To find where the problem is originating from, try setting a break point in Microsoft.VisualStudio.Tools.Applications.ProxyServices.Helper GetMap() and stepping from there.  This should give you a better idea of what is actually going on.  Also, try re-building the entire solution after making any changes.

    This exception has been a problem for others- here’s a link to a similar forum thread:  http://www.summsoft.com/forums/thread/120.aspx

     

    Hope this helps! 

                    -Melody

Page 1 of 1 (2 items) | RSS
Copyright Summit Software Company, 2008. All rights reserved.