Re: Best way to use static method functions from MC++ lib in VB.NET

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Joe Delekto (jfalcon_at_mindspring.com)
Date: 03/18/04

  • Next message: William DePalo [MVP VC++]: "Re: Best way to use static method functions from MC++ lib in VB.NET"
    Date: Wed, 17 Mar 2004 20:43:17 -0500
    
    

    Greets,

        While I've not run across it, there may be a way to make one of your
    class library DLLs automatically referenced by the Visual Studio .NET IDE.
    Certain project types add references to other .NET DLLs (such as the
    System.Web.dll), so perhaps you could create a custom project type that adds
    your control library. (Note that if you create, say, a console application,
    you have to add that reference yourself.)

        This is definitely not recommended (i.e. don't do it for production
    code!), but one MC++ project I worked on used the System namespace to
    declare a "ConsoleEx" class with static members that were meant to augment
    the .NET Framework Console functions. It would definitely be frowned upon
    for a production release, especially if there were ever a class with that
    name to be added to the framework, but it worked for me nonetheless. (I
    only used it for internal testing as a way to 'cheat' without needing a
    'using' statement specifically for that class.)

        As far as multi-threading is concerned, you only have an issue if you
    have static data members which are accessed by your static member functions.
    In that case, you would have to lock access to them between threads. If,
    however, you take all your parameters to your static member functions and
    create any interim objects and data internally (without any static members
    or variables [i.e. everything on the stack or heap and not shared between
    threads]) then you should have no problems running in a multi-threaded
    environment without any special synchronization considerations.

    Regards,

    Joe

    "Rob" <anonymous@discussions.microsoft.com> wrote in message
    news:08B3867B-35E7-46E8-B630-E8C3AC915BE6@microsoft.com...
    > I've created a MC++ library with a class that contains some static method
    functions.
    >
    > I create a reference to the library from a VB.NET application and I can
    > call the functions with no problems.
    >
    > I'm wondering if there is an alternative to creating a reference to the
    dll or assembly?
    > Is there a way to register a namespace in MC++ or VB.NET so that my class
    works like standard
    > base classes such as the Systems class using the imports statement in the
    VB.NET app?
    >
    > I'm looking for a way to make the static class as easy to use as possible
    > Do namespaces have an advantage over using the add reference feature?
    >
    > Also, I wonder if there is any impact on support for multi-threading if I
    make my
    > class method functions static?


  • Next message: William DePalo [MVP VC++]: "Re: Best way to use static method functions from MC++ lib in VB.NET"

    Relevant Pages

    • Re: path error code, why?
      ... However, a function can pass back arbitrarily many values, via a variety of mechanisms, including the return value, passing variables by reference, and passing reference types by value, all of which can be used simultaneously. ... Some have "void" as the return type, ... you've declared local variables with the same name as the static members "percentuale" and "valore". ... This may be related to the previous issue, since the CalcolaPercentuale() function uses the static members; perhaps you meant to use the parameters "a" and "b" instead of the static members. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Is this thread safe?
      ... StringBuilder bld = new StringBuilder; ... StreamWriter sw = File.AppendText; ... The String class is immutable, so once the reference has been passed in, even if other threads are reading from the class, that wouldn't affect the thread executing this method. ... Getting the StreamWriter is thread-safe, with File.AppendTextbeing a static method and so falls under the "thread-safe" qualification for static members. ...
      (microsoft.public.dotnet.framework)
    • Re: a very tricky question...
      ... members donot reside in the object but we are accessing static members ... using object reference technique. ... logically replaces a method reference with a static reference. ...
      (comp.lang.java.gui)
    • Re: What is the difference between class and type.
      ... Michael Borgwardt wrote: ... > That's not entirely true - with static members accessed through a reference ... Chris Smith - Lead Software Developer/Technical Trainer ...
      (comp.lang.java.programmer)
    • Re: Helpful Blogs or Other NGs?
      ... will reference the right DLLs for you. ... a reference to System.Data.SqlServerCe. ... Ginny Caughey ... I'm not the RDA expert around here I'm ...
      (microsoft.public.sqlserver.ce)