FAQ
For an application that is interacting with different webservers and
platforms I now need to interact with Microsoft IIS.

My goal is 'simple', retrieve a list of websites with a https binding, via
golang.

After some googling it looks like I need to use
the Microsoft.Web.Administration.dll that provides some classes that would
allow me todo the job:

*The Microsoft.Web.Administration namespace contains classes that a
developer can use to administer IIS Manager. With the classes in this
namespace, an administrator can read and write configuration information to
ApplicationHost.config, Web.config, and Administration.config files.*



*The classes in the Microsoft.Web.Administration namespace contain a series
of convenient top-level objects that allow the developer to perform
administrative tasks. The different logical objects available include
sites, applications, application pools, application domains, virtual
directories, and worker processes. You can use the API to obtain and work
with the configuration and state of these objects and to perform such
actions as creating a site, starting or stopping a site, deleting an
application pool, recycling an application pool, and even unloading
application domains.*


The namespace documentation on the msdn website:
http://msdn.microsoft.com/en-us/library/Microsoft.Web.Administration(v=vs.90).aspx

And some (old) usage examples:
http://blogs.msdn.com/b/carlosag/archive/2006/04/17/microsoftwebadministration.aspx


Now would it be a few minutes work to build something like this in the by
Microsoft supported languages but I hope someone could help me started in
golang as I can't find a lot of documentation or examples for this (besides w32
wrapper <https://github.com/AllenDang/w32> that looks really good!).

Loading the ddl is simple and completes successfully:
mwadmin =
syscall.MustLoadDLL("c:\\Windows\\System32\\inetsrv\\Microsoft.Web.Administration.dll")

But then I need to find a procedure:
mwadminSite = mwadmin.MustFindProc("SiteCollection")

Which always results in an error like this:
panic: Failed to find Microsoft.Web.Administration procedure in
c:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll: The specified
procedure could not be found.

Now I think that I can't load a class as a procedure... but how can I use
this .dll then as I can't find any other way to get started with a dll file
by linking a procedure with MustFindProc, FindProc or Find in combination
with the NewLazyDLL delayed loading.

My full example code :-)

package main

import (
"syscall"
)

var (
mwadmin =
syscall.MustLoadDLL("c:\\Windows\\System32\\inetsrv\\Microsoft.Web.Administration.dll")
mwadminSite = mwadmin.MustFindProc("Microsoft.Web.Administration")
)

func main() {
}


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Dave Cheney at Aug 24, 2013 at 8:20 am
    Silly question. Are you using a 64bit version of Go and trying to load
    a 32bit dll ?

    On Sat, Aug 24, 2013 at 6:14 PM, Paul van Brouwershaven
    wrote:
    For an application that is interacting with different webservers and
    platforms I now need to interact with Microsoft IIS.

    My goal is 'simple', retrieve a list of websites with a https binding, via
    golang.

    After some googling it looks like I need to use the
    Microsoft.Web.Administration.dll that provides some classes that would allow
    me todo the job:

    The Microsoft.Web.Administration namespace contains classes that a developer
    can use to administer IIS Manager. With the classes in this namespace, an
    administrator can read and write configuration information to
    ApplicationHost.config, Web.config, and Administration.config files.



    The classes in the Microsoft.Web.Administration namespace contain a series
    of convenient top-level objects that allow the developer to perform
    administrative tasks. The different logical objects available include sites,
    applications, application pools, application domains, virtual directories,
    and worker processes. You can use the API to obtain and work with the
    configuration and state of these objects and to perform such actions as
    creating a site, starting or stopping a site, deleting an application pool,
    recycling an application pool, and even unloading application domains.


    The namespace documentation on the msdn website:
    http://msdn.microsoft.com/en-us/library/Microsoft.Web.Administration(v=vs.90).aspx

    And some (old) usage examples:
    http://blogs.msdn.com/b/carlosag/archive/2006/04/17/microsoftwebadministration.aspx

    Now would it be a few minutes work to build something like this in the by
    Microsoft supported languages but I hope someone could help me started in
    golang as I can't find a lot of documentation or examples for this (besides
    w32 wrapper that looks really good!).

    Loading the ddl is simple and completes successfully:
    mwadmin =
    syscall.MustLoadDLL("c:\\Windows\\System32\\inetsrv\\Microsoft.Web.Administration.dll")

    But then I need to find a procedure:
    mwadminSite = mwadmin.MustFindProc("SiteCollection")

    Which always results in an error like this:
    panic: Failed to find Microsoft.Web.Administration procedure in
    c:\Windows\System32\inetsrv\Microsoft.Web.Administration.dll: The specified
    procedure could not be found.

    Now I think that I can't load a class as a procedure... but how can I use
    this .dll then as I can't find any other way to get started with a dll file
    by linking a procedure with MustFindProc, FindProc or Find in combination
    with the NewLazyDLL delayed loading.

    My full example code :-)

    package main

    import (
    "syscall"
    )

    var (
    mwadmin =
    syscall.MustLoadDLL("c:\\Windows\\System32\\inetsrv\\Microsoft.Web.Administration.dll")
    mwadminSite = mwadmin.MustFindProc("Microsoft.Web.Administration")
    )

    func main() {
    }


    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Paul van Brouwershaven at Aug 24, 2013 at 8:25 am

    On Saturday, 24 August 2013 10:20:05 UTC+2, Dave Cheney wrote:

    Silly question. Are you using a 64bit version of Go and trying to load
    a 32bit dll ?
    Good comment!

    In my example I have listed the 32 bit dll while I tested with both the
    32bit and 64bit which are both giving me the same error message.

    mwadmin =
    syscall.MustLoadDLL("C:\\Windows\\SysWOW64\\inetsrv\\Microsoft.Web.Management.dll")


    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rémy Oudompheng at Aug 24, 2013 at 8:30 am

    2013/8/24 Paul van Brouwershaven <paul@vanbrouwershaven.com>:
    On Saturday, 24 August 2013 10:20:05 UTC+2, Dave Cheney wrote:

    Silly question. Are you using a 64bit version of Go and trying to load
    a 32bit dll ?

    Good comment!

    In my example I have listed the 32 bit dll while I tested with both the
    32bit and 64bit which are both giving me the same error message.

    mwadmin =
    syscall.MustLoadDLL("C:\\Windows\\SysWOW64\\inetsrv\\Microsoft.Web.Management.dll")
    I don't think you can expect C#/.NET libraries to have the same
    interface as a usual C library. Do you know how to write a C program
    using this ?

    Rémy.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Shivakumar GN at Aug 24, 2013 at 10:16 am

    On Sat, Aug 24, 2013 at 2:05 PM, Paul van Brouwershaven wrote:
    On Saturday, 24 August 2013 10:30:18 UTC+2, Rémy Oudompheng wrote:

    I don't think you can expect C#/.NET libraries to have the same
    interface as a usual C library. Do you know how to write a C program
    using this ?
    I don't expect the same interface, my question is how I could get started
    to retrieve this information from this dll. It's normal that this would
    require more coding than with C#/.NET.

    I have legacy C++ system having encode/decode & rpc code. To integrate new
    Go code into legacy system, I wrote C wrappers for existing C++ libraries.
    This I used within Go using cgo.
    Similar approach should work for your case. Remy is likely suggesting this.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rémy Oudompheng at Aug 24, 2013 at 10:33 am

    2013/8/24 Shivakumar GN <shivakumar.gn@gmail.com>:
    On Sat, Aug 24, 2013 at 2:05 PM, Paul van Brouwershaven
    wrote:
    On Saturday, 24 August 2013 10:30:18 UTC+2, Rémy Oudompheng wrote:

    I don't think you can expect C#/.NET libraries to have the same
    interface as a usual C library. Do you know how to write a C program
    using this ?

    I don't expect the same interface, my question is how I could get started
    to retrieve this information from this dll. It's normal that this would
    require more coding than with C#/.NET.


    I have legacy C++ system having encode/decode & rpc code. To integrate new
    Go code into legacy system, I wrote C wrappers for existing C++ libraries.
    This I used within Go using cgo.
    Similar approach should work for your case. Remy is likely suggesting this.
    C++ libraries are native code, while .NET DLLs are bytecode that need
    a CLR VM to be interpreted. Googling sems to indicate that you can
    call into managed code from native code through a DllExport
    annotation or via COM.

    Rémy.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 24, '13 at 8:15a
activeAug 24, '13 at 10:33a
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase