Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-09-11
8
Medium Priority
?
450 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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