Adding Exception namespace to LINQ DAL

  • Thread starter Thread starter Alexander Wykel
  • Start date Start date
A

Alexander Wykel

I recently raninto major problems when I added the Exception namespace to the
Project which has my DBML file attached to it. Once I renamed all the
Exceptions instances to Syste.Exception the project would not recoginize any
assembly which had been added to the project, even know they were all there,
this happened to the designer.cs file that is attached to the dbml file. I
have no clue as to why this is the problem.
 
Hello Alexander,

First off, I am sorry if these major problems turn out to be caused by
Microsoft products.

I am trying to reproduce the issue that the assemblies cannot be recognized
by Visual Studio even if they were all there. But I am stuck by the step
"adding the Exception namespace to the project". In .NET framework class
library, there is no System.Exception namespace. Is the "Exception"
namespace defined by your own code? If that, when we change it to
System.Exception, we may get an compilation error "'Excpetion' is a
'namespace' but is used like a 'type'" from a code line like 'Exception e =
new Exception("");". This is because "System.Exception" is a class and
"Exception" can also be regarded as a namespace in this case. The
resolution is to explicitly specify the namespace "System" when we use
"Exception". For example, "System.Exception e = new System.Exception("");
". If I misunderstand you question, please let me know more detailed
repro-steps or send an example project to my mailbox (e-mail address removed)
so that I can have a clearer picture.

Have a good day!

Thanks
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
Figured out the problem!

The problem is that I have a namespace root called NTKSDataLayer I have a
class Logger that is defined in ths name space With in this calss the
Exception class is refrenced mutiple times.

Here is the example:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

//using Snippet.Exception;
namespace Snippet
{
public class Class1
{
public Class1()
{
try
{
if (1 != 2)
throw new System.Exception("Whoops!");
}
catch (Exception ex) //This line won't compile
{

}
}
}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snippet.Exception
{
[global::System.Serializable]
public class DALException : ApplicationException
{
//
// For guidelines regarding the creation of new exception types, see
//
http://msdn.microsoft.com/library/d.../html/cpconerrorraisinghandlingguidelines.asp
// and
//
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
//

public DALException() { }
public DALException( string message ) : base( message ) { }
public DALException( string message, System.Exception inner ) : base(
message, inner ) { }
protected DALException(
System.Runtime.Serialization.SerializationInfo info,
System.Runtime.Serialization.StreamingContext context ) : base( info,
context ) { }
}
class Exception
{
}
}

--
Alexander L. Wykel
AW Software Works
 
Hello Alexander,

Glad to see the issue was resolved with your own efforts. I am sorry that I
failed to provide constructive suggestions in my initial reply. Please feel
free to let me know if there's anything else I can help.

Regards,
Jialiang Ge ([email protected], remove 'online.')
Microsoft Online Community Support

=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================
 
Back
Top