Create a snap-in using VisualStudio 2003 C#

Hi I have to create a snap-in(for a MMC). I'm trying to do that using VS2003, C#. The .NET framework version is 1.1

I searched for information and I found a basic sample at the following

link:http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/

en-us/managedmmc/html/56f458d3-5c65-4664-8107-2ba04efd7d65.asp

I tried to compile the code, but I got an error message "The type or namespace name 'ManagementConsole' does not exist ".

So, I succesfully installed the MMC 3.0 version for XP(with SP2). I

also found the microsoft.managementconsole.dll

file(C:\Windows\system32\) and I tried to add a reference to it in my

sample project, but I got an error message: "...This is not a valid

assembly or COM component".

1. So, would it be enough to install : " Microsoft? Windows? Software

Development Kit (SDK) for the November 2005 Community Technology

Preview (CTP)." in order to run the sample at the link:

http://windowssdk.msdn.microsoft.com/library/default.asp?

url=/library/en-us/managedmmc/html/56f458d3-5c65-4664-8107-2ba04efd7d65.asp

2. Do I have to upgrade the version of the .NET framework too but continue using VS2003 and the above SDK?

3. I can use the above framework only with VS2005?

4. Or is anything else I can do?...

Thank you!

[1297 byte] By [mike_mike] at [2007-12-27]
# 1
Locks here http://www.codeproject.com/csharp/MMCFileActCs.asp
Spaccabit at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 2

Thanks for the reply.

The thing is I knew about the libraries from ironringsoftware.com, but I wanted if possible to use libraries provided in the .NET framework(a more elegant solution).

While searching for a solution, I encountered the problems presented in the first post.

So, I'll wait a little more time to see if I get an advice on working with the new Windows SDK, or any other built-in feature of the .NET framework(1.1 or 2.0) to create a snap-in.

mike_mike at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 3
I was looking at your problem. Did you look under adding referances. Look under COM objects. I found referance to the Management Module 2.0. I don't know if this help but wouldn't hurt to check it out.
BobbyStark at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 4
I didn't found

reference to Management Module 2.0. Maybe that's because I'm using VS

2003 with .NET framework 1.1. (not VS 2005 with .NET framework 2.0)

Anyway this is the code wich I would like to compile:

***********************************

using System;

using Microsoft.ManagementConsole;

namespace SimpleSnapInSample

{

[RunInstaller(true)]

public class InstallUtilSupport : SnapInInstaller

{

}


[SnapInSettings("{CFAA3895-4B02-4431-A168-A6416013C3DD}",

DisplayName = "- Simple SnapIn Sample",

Description = "Simple Hello World SnapIn")]

public class SimpleSnapIn : SnapIn

{

public SimpleSnapIn()

{

this.RootNode = new ScopeNode();

this.RootNode.DisplayName = "Hello World";

}

}

}

**************************************

mike_mike at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 5

You don't have to compile using visual studio 2005 .. you can use the .NET Framework SDK command line compiler csc.exe (it's free) ..

i compiled this sample successfully using the following batch file "Compile.bat".

@echo off
CALL "C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\sdkvars.bat"
rem csc /r:Microsoft.ManagementConsole.dll /t:library SimpleSnapInSample.cs
PAUSE

notice that i placed the Microsoft.ManagementConsole.dll beside the .cs code file.. another option is to reference it using the following switch instead:

/r:c:\Windows\System32\Micrsoft.ManagementConsole.dll

i think i tried this last one and it worked fine as well..

Now to install the Assembly simply run the following command batch "InstallSnap-in.bat":

@echo off
CALL "C:\Program Files\Microsoft.NET\SDK\v2.0\Bin\sdkvars.bat"
InstallUtil.exe SimpleSnapInSample.dll
pause

note that you'll have to put the files "microsoft.managementconsole.dll" and "MMCFxCommon.dll" beside the SimpleSnapInSample.dll for the utility to install the file successfully.

if you are using VS2005, call the following instead of "sdkvars.bat" to set your environment variables:
CALL "C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat"

Kerdany at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 6

I can confirm that the above aproach does work and the Windows Server 2003 SDK provides the ability to develop the front end of the snapin in Windows forms, excellent.

One serious problem I found however was the inability to uninstall the snapin after initial installation.

I installed using the installutil.exe from .NET 2 but was unable to uninstall or even reinstall. Has anyone seen anything like this?

I tried changing snapin GUIDs and names but to no avail. After a while something corrupted my registry and I had to reinstall windows, nice!

learnerplates at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 7
from previous post, the problem I found was an unnecessary and legacy GUID parked in my PropertyPage, this borke installutil.exe.
learnerplates at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 8

Thanx Kerdany that was very helpful!

Btw, the file MMCFxCommon.dll is installed if you install MMC 3.0.

I developed the Hello World sample, which worked fine on my machine with MMC 3.0.

I then tried to install the sample on another machine with MMC 2.0. This worked with all needed files in the bin\debug project directory. However, when I fired up MMC 2.0 (mmc.exe) it didn't appear in the list of addable Snap-Ins.

Is this just not possible (my intent was to develop a new Snap-In class using VS.NET 2005 C# for MMC 2.0) or did I miss something?

Cheers,

Pieter

psiegers at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 9
thanks for your information....

can we create a snap-in for MMC 3.0 using VS .net 1.1

I'm using C# as a my development language...

if any one has any idea, please post...

amar_soul at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 10

> can we create a snap-in for MMC 3.0 using VS .net 1.1

No, you must use .NET 2.0 or later (eg .NET 3.0).

you can use .NET 2.0 SDK, the Windows SDK for Vista (which includes .NET 3.0 SDK), or you can use Visual Studio 2005.

cheeso at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...
# 11

Hi,

I am not able to create snap-in using Framework 2.0 and MMC 3.0

i am getting the error for Snapininstaller and SnapinSettings attribute.

Error is : " The type or namespace name 'SnapInSettings' could not be found (are you missing a using directive or an assembly reference?) C:\MMC_Work\MMCTestApp\MMCTestApp\ViewSnapIn.cs 34 6 MMCTestApp "

Can anybody please help me what need to be added and what are the namespaces to be added above the class.

thank you

Praveen

Praveen77 at 2007-9-4 > top of Msdn Tech,Visual C#,Visual C# General...