Solved

How do i get my dll reference to show up in my references folder.

Posted on 2011-09-11
8
402 Views
Last Modified: 2012-05-12
I've got a class, that is part of a project, written in ASP .NET 3.5. C#. I have tried to add a reference to the Microsoft.Practices.EnterpriseLibrary.Common dll to the references folder of my the project that contains this class, but I can't find it in the list of references. However I am able to add a reference to it with a using statement, within the class. I am also able to add the reference to the main project, in its bin folder, which is why, i'm guessing, that when i try to add the reference to it, in my other project, I can't find it in the list. When I try to make a call to an attribute / property of the dll, i get an error (at compile time) telling me that the namespace could not be found, which i don't understand because, as i mentioned, it does allow me to use a using clause to pull in the library. I've added the class code. I'm not sure what I'm doing wrong or why i'm having compile time errors...
using System;
using System.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using StudyTimeTracker.Enterprise.Data;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration; //<---HERE, I'M ABLE TO ADD TO MY CLASS WITH THIS USING

namespace StudyTimeTracker.Enterprise.ExceptionHandling
{
    /// <summary>
    /// A custom exception handler that logs the key information from an exception to the Instrumentation Database.
    /// </summary>

    [ConfigurationElementType(typeof(CustomHandlerData))] //<---THIS IS WHERE I'M HAVING COMPILE TIME ERRORS

    public class SqlCustomExceptionHandler : IExceptionHandler
    {
        /// <summary>
        /// Required but not implemented.
        /// </summary>
        /// <param name="collection"></param>
        public SqlCustomExceptionHandler(NameValueCollection collection)
        {
        }

        #region IExceptionHandler Members
        /// <summary>
        /// Implements IExceptionHandler HandleException method
        /// </summary>
        /// <param name="exception">The exception that should be logged to the database</param>
        /// <param name="handlingInstanceId">The instance id</param>
        /// <returns>returns the exception that was handled</returns>
        public Exception HandleException(Exception exception, Guid handlingInstanceId)
        {
            try
            {
                WriteException(exception);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
            return exception;
        }

        #endregion

        #region Private Members
        private void WriteException(Exception exception)
        {
            STTDatabase db = new STTDatabase("Instrumentation");
            SqlCommand command = new SqlCommand();
            command.CommandType = CommandType.Text;
            command.Parameters.Add(new SqlParameter("@ExceptionTypeID", GetExceptionTypeId(exception)));
            command.Parameters.Add(new SqlParameter("@ExceptionSource", exception.Source != null ? exception.Source : String.Empty));
            command.Parameters.Add(new SqlParameter("@ExceptionMessage", exception.Message != null ? exception.Message : String.Empty));
            command.Parameters.Add(new SqlParameter("@ExceptionStackTrace", exception.StackTrace != null ? exception.StackTrace : String.Empty));
            command.Parameters.Add(new SqlParameter("@ExceptionDetail", exception.ToString()));
            command.Parameters.Add(new SqlParameter("@ExceptionOwner", Environment.MachineName));
            command.CommandText = @"
                INSERT INTO Exception_Log (Exception_Type_Id, Exception_DateTime, Exception_Source, Exception_Message, Exception_StackTrace, Exception_Detail, Exception_Owner)
                VALUES(@ExceptionTypeID, GetDate(), @ExceptionSource, @ExceptionMessage, @ExceptionStackTrace, @ExceptionDetail, @ExceptionOwner)
            ";
            db.ExecuteNonQuery(command);
        }

        private int GetExceptionTypeId(Exception exception)
        {
            int exceptionTypeId = 0;
            if (exception.Data["ExceptionTypeId"] != null)
            {
                exceptionTypeId = Convert.ToInt32(exception.Data["ExceptionTypeId"]);
            }
            return exceptionTypeId;
        }
        #endregion
    }
}

Open in new window

0
Comment
Question by:mikesExpertExchange
  • 5
  • 3
8 Comments
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36521254
Add reference to the DLL. Right click the project -> Add reference -> .NET tab -> Select Microsoft.... dll or Browse to the DLL where you have your DLL to be referred.
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 36522252
thank you, don't know why that wasn't obvious. one other question, where do i find the PublicKeyToken for dll?
0
 
LVL 16

Expert Comment

by:Easwaran Paramasivam
ID: 36522295
Assuming the DLL is in GAC. Go to assembly folder and Right click the DLL -> Properties. You can see the PublicKeyToken.
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 36522451
i've right click on it in both, the VS project folder, and Go the folder where the file lives in windows explorer and have not seen or found the jazz am I looking in the wrong places? how do I get to the assembly folder?
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 36522459
in my last post "Go"="in"
0
 
LVL 16

Accepted Solution

by:
Easwaran Paramasivam earned 500 total points
ID: 36522509
in run prompt type assembly. In my mahine it is C:\Windows\assembly
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 36522920
ok i went there and unfortunately do not see my assembly there. is there somewhere else it would be? some where else i could look? if it's not in the GAC where else might it be?
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
ID: 36524481
thank you
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.NET Error 7 42
ASP SQL Syntax Duplicate Key 7 66
Windows Service to Receive TCP Packets 4 37
fomat Json objects 6 15
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now