Solved

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

Posted on 2011-09-11
8
408 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

911 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

19 Experts available now in Live!

Get 1:1 Help Now