Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 22nd, 2005, 07:25 AM
Authorized User
 
Join Date: May 2005
Location: Melbourne, Victoria, Australia.
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Looney
Default Signed Assembly usercontrol in webform

Hi People ,
           I am newbie to embedding a Dotnet Assembly based control in an Aspx page so it behaves like a Com object.I am trying to display a Windows UserControl in a ASP.NET . I have previously managed to do so when my class library(Which contains usercontrols) was unsigned . Inorder to get my code full trust access on my own machine through IIS still , according to some info on web i decided to Strong name the assembly .Now the problem is that the same activex object (User control) work fine in a winform project but if i was to embed it in a ASP>NET page it does n't show up . I have ran Ragasm tool and gacutil.exe to do there jobs . I am sure the assembly is in the cache as well as upon running the command Gacutil /ldl
I get the following output


Microsoft (R) .NET Global Assembly Cache Utility. Version 1.1.4322.573
Copyright (C) Microsoft Corporation 1998-2002. All rights reserved.


The cache of downloaded files contains the following entries:
        ActiveXDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=987ccc4a
78937cc0, Custom=null
        ActiveXDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=987ccc4a
78937cc0, Custom=null
        ActiveXDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=987ccc4a
78937cc0, Custom=null
        ActiveXDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=987ccc4a
78937cc0, Custom=null
        ActiveXDotNet, Version=1.0.0.0, Culture=neutral, PublicKeyToken=987ccc4a
78937cc0, Custom=null
        Microsoft.VSDesigner, Version=7.0.5000.0, Culture=neutral, PublicKeyToke
n=b03f5f7f11d50a3a, Custom=null

Number of items = 6

I have set permissions everything permission for MyUserControlCodeGroup to everything
I know it 's security flaw but i just want my control to run for once and then i 'll try to narrow things down.
IIS is configured to provide Anonmous access with windows authentication check box enabled as well .
I looked up the classid for my control from windows registry and i am trying to use that in the webform following is my webform code
<%@ Page language="c#" Codebehind="Hardwaretest.aspx.cs" AutoEventWireup="false" Inherits="MyFirstActiveXObject.Hardwaretest" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Hardwaretest</title>
<META content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<META content="C#" name="CODE_LANGUAGE">
<META content="JavaScript" name="vs_defaultClientScript">
<META content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<BODY MS_POSITIONING="GridLayout">


<OBJECT id="HardwareDetector1" codeBase="http://localhost/ActiveXDotNet/bin/Debug/ActiveXDotNet.dll"
height="328" width="632" data="data:application/x-oleobject;base64,IGkzJfkDzxGP0ACqAGhvEzwhRE9DVFlQR SBIVE1MIFBVQkxJQyAiLS8vVzNDLy9EVEQgSFRNTCA0LjAgVHJ hbnNpdGlvbmFsLy9FTiI+DQo8SFRNTD48SEVBRD4NCjxNRVRBI Gh0dHAtZXF1aXY9Q29udGVudC1UeXBlIGNvbnRlbnQ9InRleHQ vaHRtbDsgY2hhcnNldD13aW5kb3dzLTEyNTIiPg0KPE1FVEEgY 29udGVudD0iTVNIVE1MIDYuMDAuMjkwMC4yNjI3IiBuYW1lPUd FTkVSQVRPUj48L0hFQUQ+DQo8Qk9EWT4NCjxQPiZuYnNwOzwvU D48L0JPRFk+PC9IVE1MPg0K"
classid="936DA01F-9ABD-4D9D-80C7-02AF85C822A8" name="HardwareDetector1" VIEWASTEXT>
</OBJECT>

<FORM id="Form1">
<INPUT id="Text1" style="WIDTH: 200px; HEIGHT: 22px" type="text" size="28" value="enter WMI Object Name here"
name="txt"><INPUT id="Button1" onclick="doScript();" type="button" value="Click me" name="Button1">
</FORM>

<SCRIPT language="javascript">
      function doScript()
       {


       }
</SCRIPT>
</BODY>
</HTML>
The code for my usercontrol is
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using System.Management;
using System.IO;
using System.Security;
using System.Security.Permissions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly:AllowPartiallyTrustedCallers]
namespace ActiveXDotNet
{ [Guid("F9168C5E-CEB2-4faa-B6BF-329BF39FA1E4")]
    public interface AxHardwareDetector
    {

    }
    /// <summary>
    /// Summary description for HardwareDetector.
    /// </summary>
    ///
    [Guid("936DA01F-9ABD-4d9d-80C7-02AF85C822A8")]
    public class HardwareDetector : System.Windows.Forms.UserControl,AxHardwareDetecto r
    {
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.DataGrid datagrid1;
        private System.Windows.Forms.ComboBox comboBox1;
        private System.Windows.Forms.Button button1;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.Button button2;
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.Container components = null;

        public HardwareDetector()
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            // TODO: Add any initialization after the InitializeComponent call
            Attribute AxHardwareDetectorAttribute = Attribute.GetCustomAttribute( typeof( AxHardwareDetector ), typeof( GuidAttribute ) );

            // The Value property of GuidAttribute returns a string.
            System.Console.WriteLine( "AxHardwareDetectorAttribute: " + ((GuidAttribute)AxHardwareDetectorAttribute).Value );

        }

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose( bool disposing )
        {
            if( disposing )
            {
                if(components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose( disposing );
        }

        #region Component Designer generated code
        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.label2 = new System.Windows.Forms.Label();
            this.datagrid1 = new System.Windows.Forms.DataGrid();
            this.comboBox1 = new System.Windows.Forms.ComboBox();
            this.button1 = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.button2 = new System.Windows.Forms.Button();
            ((System.ComponentModel.ISupportInitialize)(this.d atagrid1)).BeginInit();
            this.SuspendLayout();
            //
            // label2
            //
            this.label2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.label2.ForeColor = System.Drawing.Color.Brown;
            this.label2.Location = new System.Drawing.Point(8, 116);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(136, 23);
            this.label2.TabIndex = 13;
            this.label2.Text = "Details";
            //
            // datagrid1
            //
            this.datagrid1.DataMember = "";
            this.datagrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
            this.datagrid1.Location = new System.Drawing.Point(8, 140);
            this.datagrid1.Name = "datagrid1";
            this.datagrid1.Size = new System.Drawing.Size(656, 264);
            this.datagrid1.TabIndex = 17;
            //
            // comboBox1
            //
            this.comboBox1.Items.AddRange(new object[] {
                                                           "Win32_DiskDrive",
                                                           "Win32_OperatingSystem",
                                                           "Win32_Processor",
                                                           "Win32_ComputerSystem",
                                                           "Win32_StartupCommand",
                                                           "Win32_ProgramGroup",
                                                           "Win32_SystemDevices"});
            this.comboBox1.Location = new System.Drawing.Point(8, 84);
            this.comboBox1.Name = "comboBox1";
            this.comboBox1.Size = new System.Drawing.Size(456, 21);
            this.comboBox1.TabIndex = 16;
            //
            // button1
            //
            this.button1.Location = new System.Drawing.Point(480, 84);
            this.button1.Name = "button1";
            this.button1.TabIndex = 15;
            this.button1.Text = "Show";
            this.button1.Click += new System.EventHandler(this.button1_Click);
            //
            // label1
            //
            this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
            this.label1.ForeColor = System.Drawing.Color.Brown;
            this.label1.Location = new System.Drawing.Point(8, 60);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(608, 23);
            this.label1.TabIndex = 14;
            this.label1.Text = "Select the win32 API or type in a new one. Then click on the \"Show\" button.";
            //
            // button2
            //
            this.button2.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            this.button2.Location = new System.Drawing.Point(576, 84);
            this.button2.Name = "button2";
            this.button2.TabIndex = 12;
            this.button2.Text = "Cancel";
            this.button2.Click += new System.EventHandler(this.button2_Click);
            //
            // HardwareDetector
            //
            this.Controls.Add(this.label2);
            this.Controls.Add(this.datagrid1);
            this.Controls.Add(this.comboBox1);
            this.Controls.Add(this.button1);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.button2);
            this.Name = "HardwareDetector";
            this.Size = new System.Drawing.Size(704, 464);
            ((System.ComponentModel.ISupportInitialize)(this.d atagrid1)).EndInit();
            this.ResumeLayout(false);

        }
        #endregion

        private void button1_Click(object sender, System.EventArgs e)
        {
            datagrid1.DataSource = GetStuff(comboBox1.Text);
        }
        public ArrayList GetStuff(string queryObject)
        {
            ManagementObjectSearcher searcher;
            int i = 0;
            ArrayList hd = new ArrayList();
            try
            {
                searcher = new ManagementObjectSearcher("SELECT * FROM " + queryObject);
                foreach(ManagementObject wmi_HD in searcher.Get())
                {
                    i++;
                    PropertyDataCollection searcherProperties = wmi_HD.Properties;
                    foreach (PropertyData sp in searcherProperties)
                    {
                        hd.Add(sp);

                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            return hd;
        }

        private void button2_Click(object sender, System.EventArgs e)
        {
            //this.Close();
        }
    }
}


Please suggest what am i doing wrong , cause for the life in me i cannot go with this wild goose chase i have been on since early hours of today .I am not sure where exactly the problem is , but i know it all started soon after i started following this tutorial on Microsoft's web site to make signed assembly.Any ideas or suggestions would be very highly appreciated .Thanxs in advance
Cheers :-)

Looney!
__________________
Looney!
Reply With Quote
  #2 (permalink)  
Old May 22nd, 2005, 06:06 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

This is not the .net area of the forum

Wind is your friend
Matt
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
content hash found in signed attributes different Dexray BOOK: Beginning Cryptography with Java 1 April 9th, 2008 03:49 PM
Send Digitally-signed CDO emails kieronmc Classic ASP Professional 1 May 25th, 2006 08:08 AM
I signed a .cab file and its still bloked by windo sugar VBScript 0 April 28th, 2006 07:33 PM
Extract from file cannot be signed connlichan Infopath 0 October 24th, 2005 08:10 PM
Signed Applet example? EhobaX Java GUI 1 January 6th, 2004 06:00 AM



All times are GMT -4. The time now is 10:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.