Usually if you add a network printer under one user on Windows XP, you have to add the same printer on the other user accounts on the same computer. Here is how you can permanently add a network printer that is visible to all users logging into that computer:
rundll32 printui.dll,PrintUIEntry /ga /c\\[Local Computer Name] /n\\[Network Computer name]\[Shared Printer Name].
Then, you need to restart the printer spooler service by doing the following:
1. Go to Control Panel --> Administrative Tools --> Services
2. Locate "Print Spooler" and right-click it.
3. Click Restart
The new printer should now show up in Control Panel-->Printers and Faxes.
I hope somebody else finds this useful.
Wednesday, February 6, 2008
Saturday, February 2, 2008
Reflection and Medium Trust
Up to today I thought if you host a website in a Medium Trust environment for .NET, reflection is basically turned off or not allowed. It was rather frustrating to not be able to use some of the nice abilities that reflection provides because the website is hosted in a Medium Trust environment. However, reflection IS still allowed, but whatever you are looking for has to be marked as public. For example, I had a class that looked something like the following:
internal class MyClass
{
private bool _someProperty;
public bool SomeProperty
{
get { return _someProperty; }
set { _someProperty = value; }
}
}
Because the class is marked "internal", it is not accessible using reflection in a Medium Trust environment. Just by changing "internal" to "public", I was able to query the classes properties using reflection:
public class MyClass
{
...
}
I hope someone else finds this useful.
internal class MyClass
{
private bool _someProperty;
public bool SomeProperty
{
get { return _someProperty; }
set { _someProperty = value; }
}
}
Because the class is marked "internal", it is not accessible using reflection in a Medium Trust environment. Just by changing "internal" to "public", I was able to query the classes properties using reflection:
public class MyClass
{
...
}
I hope someone else finds this useful.
Friday, February 1, 2008
User Defined Function Error
I wanted to post this so that I won't forget how to fix it and also in case somebody else runs into the same issue.
In SQL Server 2005, I had a function that returned all records from a certain table:
SELECT * FROM Employees;
Best practices would be to not return all fields, but I don't care. I got the error:
View or function 'dbo.FunctionName' has more column names specified than columns defined.
I simply had to rebuild the function and all was well.
UPDATE: Sometimes this error is a lot harder to catch! Instead of getting the error, it was just shifting all the columns and so the values returning from the function were in the wrong columns! I think I better start specifying fields explicitly.
In SQL Server 2005, I had a function that returned all records from a certain table:
SELECT * FROM Employees;
Best practices would be to not return all fields, but I don't care. I got the error:
View or function 'dbo.FunctionName' has more column names specified than columns defined.
I simply had to rebuild the function and all was well.
UPDATE: Sometimes this error is a lot harder to catch! Instead of getting the error, it was just shifting all the columns and so the values returning from the function were in the wrong columns! I think I better start specifying fields explicitly.
Subscribe to:
Posts (Atom)