Implementing DLL

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



The problem is an implementation of a extension for the Active Directory
users and computers snap in
in the microsoft management console.

Language: c#
Platform Windows XP

Only the Computers Object is to be extended.
[SnapInSettings("{{FE2EE5B3-8BEE-4729-B959-50A69C423FA2}}",
DisplayName = "- Computer Info",
Description = "Adds a Property Page to Computer
Management")]
[ExtendsNodeType("{bf967a86-0de6-11d0-a285-00aa003049e2}")]//
computer in ad users and computers
I can't use the register option of the Visual Studio, because I have
to install the extension on all computers in the network by a batch
job.
So I tried copying the DLL in die Windows\system32 folder and used the
tool regasm "C:\windows\system32\propext.dll"
Here I'm getting the message that it registered successfully.
But I can't find the extension in the MMC under computers.

so I tried installutil.exe, which sais:

Ausnahmefehler beim Suchen der Installer in der Assembly
C:\WINDOWS\assembly\GAC
_MSIL\RuagProp\1.2.7.0__f48f104487524ced\RuagProp.dll.
System.Reflection.ReflectionTypeLoadException: Mindestens ein Typ in der
Assembl
y kann nicht geladen werden. Rufen Sie die LoaderExceptions-Eigenschaft ab,
wenn
Sie weitere Informationen benötigen.
Die Installation von
C:\WINDOWS\assembly\GAC_MSIL\RuagProp\1.2.7.0__f48f10448752
4ced\RuagProp.dll wird abgebrochen.

Während der Installationsphase ist eine Ausnahme aufgetreten.
System.InvalidOperationException: Die Installertypen in der Assembly
C:\WINDOWS\
assembly\GAC_MSIL\RuagProp\1.2.7.0__f48f104487524ced\RuagProp.dll können
nicht a
bgefragt werden.
Die interne Ausnahme System.Reflection.ReflectionTypeLoadException wurde mit
fol
gender Fehlermeldung ausgelöst: Mindestens ein Typ in der Assembly kann
nicht ge
laden werden. Rufen Sie die LoaderExceptions-Eigenschaft ab, wenn Sie
weitere In
formationen benötigen..
meaning: a type in the assembly is missing.
So I tried using the autoregister function of VS2005. But here i get the
error:

Fehler 10 Die C:\1\bin\Debug\RuagProp.dll-Assembly kann nicht registriert
werden. Die Datei oder Assembly Microsoft.ManagementConsole, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35 oder eine Abhängigkeit davon
wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.

meaning: the assembly can't be registered. The File or Assembly
Microsoft.ManagementConsole ... or a Dependency is missing. Can't find the
file.

So I reinstalled MMC3.0, Windows SDK, copied the
microsoft.managementconsole.dll and MMCFxCommon.dll in the folder of the
Project, deleted the reference for managementconsole.dll and reloadet the one
from the project folder.
still i can't register the project.


Am I missing some steps in registering or why the Snap In is not showing?

Here is documented how to add a Property Sheet "AD Users and Computers Snap
In" in the MMC 3.0: http://msdn2.microsoft.com/en-us/library/ms692751.aspx
My Code is also based on this example.
I already had this Extension showing in the user-node of the "AD Users and
Computers Snap In" last year.
I thought, I just have to change the ID of the extended node into the
computer object of this snap in. (took it from here:
http://msdn2.microsoft.com/en-us/library/ms680987.aspx), but that doesn't
work. I could not find anything how to solve this problem.
I also generated a new GUID and changed it.
But strangehow I can't register the changed one.

I also checked if it is a strong name, here the sn return:
C:\Program Files\Microsoft Visual Studio 8\VC>sn -v
C:\1\bin\debug\ruagprop.dll
Microsoft (R) .NET Framework-Dienstprogramm für starke Namen
Version 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
The Assembly "C:\1\bin\debug\ruagprop.dll" is valid.
--> strong name
(I included a Key in the Compiler)
So that is not the problem.

Here is the Code of the Extension.cs :

Code Snippet
//=======================================================================================
//
// This source code is only intended as a supplement to existing Microsoft
documentation.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//
// Copyright (C) Microsoft Corporation. All Rights Reserved.
//
//=======================================================================================
//
// Purpose:
// Shows how to create an ExtensionPropertySheet for the Computer Management
snap-in .
//
//=======================================================================================
//
// Description:
// Uses the ExtendsNodeType attribute and the Guid of the ‘Computer
Management’
// snap-in root node to create a ExtensionPropertySheet. Uses the shared data
// features to get some data from the primary and use it in the Extension
sheet.
//
//=======================================================================================
using System;
using System.Text;
using System.Configuration.Install;
using System.ComponentModel;
using System.Security.Permissions;
using System.Windows.Forms;
using Microsoft.ManagementConsole;
using Microsoft.ManagementConsole.Advanced;
[assembly: PermissionSetAttribute(SecurityAction.RequestMinimum,
Unrestricted = true)]
namespace Microsoft.ManagementConsole.Samples
{
/// <summary>
/// RunInstaller attribute - Allows the .Net framework InstallUtil.exe to
install the assembly.
/// SnapInInstaller class - Installs snap-in for MMC.
/// </summary>
[RunInstaller(true)]
public class InstallUtilSupport : SnapInInstaller
{
}
/// <summary>
/// Property sheet extension for the root node of Computer Management snap-in.
/// </summary>
[SnapInSettings("{{FE2EE5B3-8BEE-4729-B959-50A69C423FA2}}",
DisplayName = "- RUAG Computer Info",
Description = "Adds a Property Page to Computer Management")]
[ExtendsNodeType("{bf967a86-0de6-11d0-a285-00aa003049e2}")]//computer ind ad
users and computers
public class RUAGProp : PropertySheetExtension
{
private SharedDataItem sharedDataItem;
/// <summary>
/// Extension class to extend the Computer Management snap-in property sheet
/// </summary>
public RUAGProp()
{
// In order to receive published data from the primary snap-in, MMC needs to
know which
// data items the extension is interested in.
// sharedDataItem = new SharedDataItem("lpIDataObject");
// sharedDataItem = new SharedDataItem("DSOBJECT");
sharedDataItem = new SharedDataItem(@"DSOBJECTNAMES");
this.SharedData.Add(sharedDataItem);
// sharedDataItem = new SharedDataItem("DSOBJECTNAMES");
// this.SharedData.Add(sharedDataItem);
}
/// <summary>
/// Initialization notification.
/// </summary>
protected override void OnInitialize()
{
}
/// <summary>
/// Virtual method that is called to get the extension pages.
/// </summary>
/// <param name="propertyPageCollection">Page collection.</param>
protected override void OnAddPropertyPages(PropertyPageCollection
propertyPageCollection)
{
const int OFFSET_SELECTED_OBJECTS_COUNT = 16;
MarshalBuffer buffer = new MarshalBuffer(sharedDataItem.GetData());
int selectedCount = buffer.ReadInt(OFFSET_SELECTED_OBJECTS_COUNT);
//Propertypage should not be displayed if multiple objects are selected.
if (selectedCount == 1)
{
// add extension page.
// UserPropertyPage is the class inherited from PropertyPage and is called
MachinePropertyPage in the SDK sample.
MachinePropertyPage machinePropertyPage = new
MachinePropertyPage(sharedDataItem);
propertyPageCollection.Add(machinePropertyPage);
}
}





} //class
public class MarshalBuffer
{
byte[] _buffer = null;

public MarshalBuffer(uint size)
{
_buffer = new byte[size];
}

public MarshalBuffer(byte[] buffer)
{
_buffer = buffer;
}

public int ReadInt(uint offset)
{
return BitConverter.ToInt32(_buffer, (int)offset);
}

public long ReadChar(uint offset)
{
return BitConverter.ToChar(_buffer, (int)offset);
}

public string ReadString(uint offset)
{
StringBuilder str = new StringBuilder();
uint i = 0;
while (this.ReadChar(offset + i) != (char)0)
{
str.Append((char)this.ReadChar(offset + i));
i = i + 2;
}
return str.ToString();
}
}
} // namespace
.



Relevant Pages

  • Re: Pathfinder RPG?
    ... Kyle Wilson wrote: ... I've been fixing computers for 25 years. ... Yes, fans are my nemesis. ... Even the good ones die from failed bearings ...
    (rec.games.frp.dnd)
  • Re: Why is the Installation Process so Slow for World of Warcraft?
    ... they don't die because they are still very useful. ... Most people do not play respurce intensive games on their computers, ... Same with the obsolete floppy disk drive. ... people for no reason whatsoever. ...
    (alt.games.warcraft)
  • Re: Efficient way to determine if PCs are on or off
    ... >I'm looking for a way to query a text list of netbios PC names, ... computers and it runs for about 6 hours for the first run. ... NBTSTAT.EXE provides public information about the NETbios of ... Die Katzen sind Wörter mit Pelz. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • Re: Excel 2007 - File Open and Repair
    ... PS non of these computers has received the install yet for the sp2 packages. ... system to generate the extension. ... Excel 2007 - File Open and Repair ...
    (microsoft.public.excel.crashesgpfs)
  • Re: Large files being written to c:winnt emp
    ... extension on them (make sure that extensions of known file types is ... >done near these time periods. ... >automatic downloads of the windows updates but even then ... Of 25 computers on a network, ...
    (microsoft.public.win2000.security)