Unable to generate a temporary class (result=1). error CS2001: Source file ‘C:\WINDOWS\TEMP\filename.cs’ could not be found error CS2008: No inputs specified

Hi,

I was getting this error when I was trying to call a .NET dll from an ASP page.

The dll was making use of a web service.

And while searching for it I found that if we are making use of a web service from

an asp page, the page tries to create a temporary file in windows\temp directory and because it hasn’t got rights for the same we get the error.

 

We can resolve it by giving it the appropriate rights for the windows/temp folder

 

1) Right click the temp folder à Select properties

2) Go to security tab

3) Click on Add and add ASPNET account. ( In locations select your machine )

4) Then add one more account IWAM_D-0824 (i.e. IWAM_YourMachineName)

5) Try running the ASP page again. The page should run without any error.

Bye

Using .NET Assembly (DLL) in ASP page

1. Create a Assembly file using following:
        File >> New >> Project >> Class Library >> Name = MyLibCSharp
 
2. Add a function HelloWorld. Code will look as follows:

using System;

using System.Collections.Generic;

using System.Text;

using System.Runtime.InteropServices;

namespace MyLibCsharp

{

[Guid(“FE1EB79E-3513-487e-ADFF-2B61C6CB4730”)]

[ComVisible(true)]

public class Class1

{

public String HelloWorld(String name)

{

return (“Hellow World; Welcome “ + name);

}

}

}

3. Sign the Assembly (To enable it to be used by multiple Applications):

Go to Project >> MyLibCSharp Properties >> Signing >> Sign the Assembly >> New >> Key.snk

4. Enable for COM Interop:

Go to Project >> MyLibCSharp Properties >> Build >> Output >> Check the “Register for COM interop.

5. Build the Assembly.

6. Add to GAC using “Visual Studio Command Prompt” the assembly is located in DEBUG/RELEASE folder.

gacutil -I MyLibCSharp.dll

7. Execute the following:

Regasm /tlb /codebase MyLibCSharp.dll

8. ASP code:

<%

Dim foo

set foo = Server.CreateObject(“MyLibCSharp.Class1”)

Response.Write (foo.HelloWorld(“test”))

%>

9. To unregister the assembly

Regasm /unregister MyLibCSharp.dll

10. And to remove the same from GAC (Global assembly cache)

Go to

C:\WINDOWS\assembly

find the assembly you want to remove

select it , right click it and select uninstall

Bye

 

Unable to start debugging. The Machine Debug Manager is disabled

Occasionally I used to receive this error

“Unable to start debugging. The Machine Debug Manager is disabled” when I try to run the solution from visual studio in debug mode.

The reason for this was Machine Debug Manager was in disabled state or not started.

So the solution for this is

 

1) Go to control panel.

2) Then Administrative Tools

3) Then services.

4) In services find the service named Machine debug manager.

 

Enable the service and start it if disabled or stopped.

 

Bye

Reflector -Nice tool for .NET developer

Reflector is a nice tool developed by Lutz Roeder.

It is somewhat similar to .Net ILDASM (Intermediate Language Dissembler).

The best thing about it is that we can even view the source code that also in different languages

C#, VB.NET, Delphi even the IL code itself.

 

This is the link

http://www.aisto.com/roeder/dotnet/

 

There are other good tools as well.

 

Do check it.

Nice website for C# developer

Hi,
Do check out this very very useful web-site for c# developer for understanding
multi threading and it has got some wonderful tools like

QueryExpression – which has an user interface similar to query analyzer using which we can query oracle, sql server and other databases. It is also very light weight.

And
LinqPad for practicing the Linq syntax.

http://www.albahari.com/index.html

Creating custom application exception C#

Hi,

There are times when we are creating a custom class and the class needs to have it’s own application specific exception which can be thrown so that calling program can be aware of the error condition.

Say we have a class named BillingUpdate which has a condition that the billing amount should never be less than 10,000.

Say it has a function which accepts billing amount in one of it’s methods as a parameter and we need to make the user of this function aware of the condition that it can’t take billing amount less than 10000.

In this case what we can do is

create a custom class BillingException which inherits SystemException class

// creating a custom class that inherits from SystemException.
class BillingException :SystemException
{
// overloading the constructor for passing the message associated with the exception
public BillingException(string message)
: base(message)
{
}
}

Now to use this exception class we can do the following

public void GetBillingAmount(decimal billingAmount)
{
if(billingAmount < 10000M)
{
throw new BillingException(“Billing amount can’t be less than 10000”);
}
}

And the calling code can do something like this

BillingUpdate billingUpdate = new BillingUpdate();
try
{
billingUpdate.GetBillingAmount(9000M);
}
catch(
BillingException ex)
{
MessageBox.Show(ex.Message);
}

Bye