A lot of my C# code follows this pattern:
void foo(string param1, string param2, string param3)
{
try
{
// do something...
}
catch(Exception ex)
{
LogError(String.Format("Error in foo(param1={0}, param2={1}, param3={2}), exception={3}", param1, param2, param3, ex.Message));
}
}
Is there a way i...
I realize there is a somewhat related thread on this here:
http://stackoverflow.com/questions/22012/loading-assemblies-and-its-dependencies
But I am modifying something and this doesn't exactly apply.
string path = Path.GetDirectoryName( pathOfAssembly );
Environment.CurrentDirectory = path;
Assembly.Load(Path.GetFileNameWithoutExte...
It is discouraged to simply catch System.Exception, instead only the "known" Exceptions should be caught.
Now, this sometimes leads to unneccessary repetetive code, for example:
try
{
WebId = new Guid(queryString["web"]);
}
catch (FormatException)
{
...
All throughout an application wherever error messages (or other user messages) are used I typically hard-code a string. Obviosly this can be really bad (especially when you may have to come back and localize an app). What is the best approach to centralize these strings? A static class? Constants? An XML File? Or a combination (like crea...
Silverlight works on client side so putting any sensitive data like connection strings, passwords etc. in the code seems not to be a good thing. I want to build whole web app in Silverlight doing lots of authorization and database quering things. How to make it safe? Any tips&tricks and what things should I avoid?
...
I am trying to leverage ORM given the following requirements:
1) Using .NET Framework (latest Framework is okay)
2) Must be able to use Sybase, Oracle, MSSQL interchangeably
3) The schema is mostly static, BUT there are dynamic parts.
I am somewhat familiar with SubSonic and NHibernate, but not deeply.
I get the nagging feeling that th...
This could be weird, Have you ever come across a blog which you wanted to read in the chronological order? And that blog could be old, with several hundred posts. When i add this feed to my feed reader, say googlereader, the latest feed comes on top and as i scroll down further, the older posts appear. This could be frustrating if you wa...
I need to generate a new interface at run-time with all the same members as an existing interface, except that I will be putting different attributes on some of the methods (some of the attribute parameters are not known until run-time). Can anyone assist?
...
FYI: I am running on dotnet 3.5 SP1
I am trying to retrieve the value of an identity column into my dataset after performing an update (using a SqlDataAdapter and SqlCommandBuilder).
After performing SqlDataAdapter.Update(myDataset), I want to be able to read the auto-assigned value of myDataset.tables(0).Rows(0)("ID"), but it is System...
Is there a way through the .net framework to determine if a folder is shared or not?
Neither Diretory, DirectoryInfo or FileAttributes seem to have any corresponding field.
One thing I forgot to mention was that I want to be checking for network shares. But I'll investigate the WMI stuff.
...
How can I compare the content of two (or more) large .resx files? With hundreds of Name/Value pairs in each file, it'd be very helpful to view a combined version. I'm especially interested in Name/Value pairs which are present in the neutral culture but are not also specified in a culture-specific version.
...
I'd like to log stuff in my Sharepoint Web Parts, but I want it to go into the ULS. Most examples that I've found log into the Event Log or some other file, but I did not really find one yet for logging into the ULS.
Annoyingly, Microsoft.SharePoint.Diagnostics Classes are all marked Internal. I did find one example of how to use them a...
I've got a code like this :
Dim Document As New mshtml.HTMLDocument
Dim iDoc As mshtml.IHTMLDocument2 = CType(Document, mshtml.IHTMLDocument2)
iDoc.write(html)
iDoc.close()
However when I load an HTML like this it executes all Javascripts in it as well as doing request to some resources from "html" code.
I want to disable javascript...
I want to test a connection to a machine in my local intranet. I know the IP address.
What port number should I use? 555? BTW: I'm using .NET.
...
So for the past day or so I have been fixing a bug that is caused by a modal dialog. I work on an application which communicates with the server through the Windows message pump. When I use ShowDialog() to show a modal form, the message pump is blocked and none of my messages are processed, yet they do build up in the queue (expected b...
Is it possible to reference a .NET Assembly from a SQL Server Stored procedure or function, or otherwise access the clr code from SQL Server?
EDIT Whilst this solution will require to be somewhat generic, I am fairly confident expecting SQL 2005+
...
In VB.NET (or C#) how can I determine programmatically if a public variable in class helper.vb is used anywhere within a project?
Thanks in advance.
...
What is the slickest way to initialize an array of dynamic size in C# that you know of?
This is the best I could come up with
private bool[] GetPageNumbersToLink(IPagedResult result)
{
if (result.TotalPages <= 9)
return new bool[result.TotalPages + 1].Select(b => true).ToArray();
...
Thanks!
Rob
...
At my last place of employment, I used BTS quite a bit. However, I've noticed that managers often want to use it for the wrong things, and developers are hesitant to adopt it.
So, I'm just wondering, how's BTS being used? Please post experiences, not theories.
Thanks!
...
Is there a way to tell if an event handler has been added to an object? I'm serializing a list of objects into/out of session state so we can use SQL based session state... When an object in the list has a property changed it needs to be flagged, which the event handler took care of properly before. However now when the objects are des...