Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2011-09-11
8
Medium Priority
?
456 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:Michael Sterling
  • 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:Michael Sterling
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Michael Sterling
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
 
LVL 1

Author Comment

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

Accepted Solution

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

Author Comment

by:Michael Sterling
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:Michael Sterling
ID: 36524481
thank you
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Screencast - Getting to Know the Pipeline

885 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