Hi all, I'm playing around with Microsoft SharePoint (2.0) and I'm going through some examples in the SDK. I'm at a step which describes using Visual Studio .NET to create a new Web application on the SP server side. I've run into a problem which doesn't seem to be very well covered on the net. Unable to create the web "http://server/_layouts/SPTest". Server error: The folder "_layouts/SPTest" is reserved for use by the Web server. A Web may not be created under this URL.
I'm running Windows XP and attempting to connect to the SP server, which is a separate Windows 2003 machine. I've had a look at this link as it describes my problem, but in my case I don't get any errors in the event log both on the server and client side. So I'm guessing the solution will be somewhat different. Has anyone encountered this? How do I solve this problem? Thanks in advance, Sam
serious sam
Posts
-
Creating new Web on SharePoint server -
System.DirectoryServices and SSL Certificate PoliciesHi all, I am interested in the way SSL Certificates are validated when using SecureSocketsLayer authentication to access a directory service over LDAP. Without going too much into it, this is what works:
DirectoryEntry searchRoot = new DirectoryEntry(location, username, password, AuthenticationTypes.SecureSocketsLayer); object nativeObject = m_searchRoot.NativeObject; searchRoot.RefreshCache();
Of course, it only works when correct certificates are installed on the machine attempting to execute this code. If the certificates are not installed, then the SSL connection supporting the DirectoryEntry fails with a COMException, claiming the server is not operational. I would like to find where exactly the certificate is being checked, so I can override the validation behaviour. I need something similar to what is described here, but applies to a DirectoryEntry. The approach specified in the link doesn't solve my problem -- it doesn't seem like the System.Net.ServicePointManager.CertificatePolicy is used at all in my code. Does anyone have any ideas? Thanks in advance. Cheers, Misha -
Exception handling in .NETThank you. That is a very insightful article. It sheds a lot of light on the topic. The author makes points that are both relevant and valid. While I can't say I agree with all of them 100%, I can now see that there is indeed more than one way to skin a cat. Of particular interest is his approach to exception handling -- heavier use of the try-finally to free any acquired resources, and a centralised exception handler to actually deal with the exception. After reading that article, however, one particular paragraph bothered me:
From the article:
But that said, there's certainly tremendous value in knowing what exceptions can get thrown, and having some sort of tool that checks... But I think we can certainly do a lot with analysis tools that detect suspicious code, including uncaught exceptions, and points out those potential holes to you.
Now, I would like to know -- what publicly available tools like that are out there? Thanks. Cheers, Misha
-
Exception handling in .NETHi all, I've recently had to work on a .NET web application. Now, although I've been familiar with .NET for approximately a year now, I'm primarily a Java developer. And while I think .NET is a great idea, there is one thing I don't quite understand about it -- the way exceptions are handled. In particular, I'm dissapointed by the lack of checked exceptions. A method does not need to declare that it may throw an exception, making it harder to manage the propagation of exceptions in your programs. Perhaps a simple example to demonstrate... Java:
// Read in a single line from the specified file and return it static void myReadLine(String filename) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(filename)); return reader.readLine(); }
C#:// Read in a single line from the specified file and return it static void MyReadLine(string filename) { StreamReader reader = new StreamReader(filename); return reader.readLine(); }
It's pretty obvious what both methods are doing, and that they are doing it in pretty much the same way. The main difference is in how those methods can now be used. In C#.NET, you can call MyReadLine() from anywhere in your code and everything will happily compile. If things go wrong and an System.IOException is thrown in that method, then unless you've done your homework and surrounded the call to MyReadLine() with a try-catch block, your application will crash. With a pretty stack trace printed on the screen. Ungracefully. In Java, the code will not even compile unless you are explicitly catching that exception when calling myReadLine(). An IOException is a checked exception in Java -- meaning that if it's ever thrown, it must be caught somewhere in your code. Other exceptions, such as, say NullPointerException, are run-time exceptions and do not have to be explicitly caught (although sometimes it's not a bad idea to do so). In .NET, it seems, all exceptions are considered run-time. Even if you happened to know that StreamReader.ReadLine() throws an exception, there's a fair chance that some methods in your code could throw exceptions without you even knowing it. And if they can, then they will -- at the worst possible time, naturally. So your options are either keep your fingers crossed, or trawl through the documentation, checking for possible exceptions for each method your code is calling. Neither option is particularly appealing. Nor is catching the general Syst -
JOIN two objects from different sourcesHi all, I have a situation where I have a table in my SQL Server 2000 database, and another table stored as a .csv file. I would like to perform a join on the two tables. Is it possible to do this without entering the data in the .csv table into the SQL Server database? I am using C#.NET for this stuff. Cheers, Michael
-
Static linkingOk, thanks, that's cleared it up a bit. I've asked around work and managed to dig up the DLLs I needed. So that's taken care of. Thanks to both of you for helping. Cheers, Penkov
-
Static linkingThank you for your reply.
cmk wrote:
A static library .lib file is not the same as a .lib file used to link to a dll.
I was under the impression that they are all static libraries... Could you please elaborate? How do I distinguish between one type of .lib file and another? I haven't done much Windows C++ development (up until now only had to work on Linux). If you could point me in the direction where I can read a bit more about this, it would be great. Thanks again, Penkov
-
Static linkingThank you for your reply. The options you suggested seem to apply only to the standard C run-time libraries which are provided by MS. My problem is that I need to statically link to my own libraries. I've tried playing around with the /link option, but I have not had any luck with it. Do you have any other suggestions? Thanks in advance. Penkov
-
Static linkingHello all, Could anyone explain how to link a library statically into an executable in Visual C++ .NET? My problem is that I'm compiling against library (.lib) files, but I do not have the corresponding (.dll) files. The compilation works fine, but when I attempt to run the application, it falls over as it is not able to find the .dll. It is my understanding that if I statically link the required parts from the .lib files into the executable, it will have everything it needs at run-time and will not go off looking for the .dll. I've looked around the compiler and linker settings within Visual C++ and haven't been able to find anything to make me happy. Googling hasn't produced anything either. Could someone suggest a solution? Cheers, Penkov
-
Weird class cast issueWith the help of a workmate, I've resolved the issue. The quirk was in the Add method of the DataColumnCollection class (which holds the cells for the rows). The writers of the method, in their infinite wisdom, convert the input value to a string before adding it. This is default behaviour. It can be overridden by creating a custom DataColumn to hold the type of the input data. I'm including the code which now works.
using System; using System.Data; using System.Collections; class CastTest { const string COL = "test"; static void Main() { Console.WriteLine("CastTest"); ArrayList list = new ArrayList(); string str = "Hello world"; list.Add(str); Console.WriteLine("arrayList created"); DataTable table = new DataTable(); DataColumn dC = new DataColumn(COL, list.GetType()); table.Columns.Add(dC); DataRow row = table.NewRow(); table.Rows.Add(row); row[COL] = list; Console.WriteLine("table created"); object resultObj = table.Rows[0][COL]; Console.WriteLine("resultObj type: " + resultObj.GetType()); ArrayList resultList = (ArrayList) resultObj; string resultStr = (string)resultList[0]; Console.WriteLine(resultStr); } }
I guess I should be reading the documentation more closely so that I would be more aware of "features" like this ;) Thanks for the replies. Regards, Michael -
Weird class cast issueHi all, I'm having a problem using class casts. I'm storing an ArrayList inside a DataTable, and when I want to retrieve the list, I get an InvalidCastException. Here is my code:
using System; using System.Data; using System.Collections; class CastTest { const string COL = "test"; static void Main() { Console.WriteLine("CastTest"); ArrayList list = new ArrayList(); string str = "Hello world"; list.Add(str); Console.WriteLine("arrayList created"); DataTable table = new DataTable(); DataRow row = table.NewRow(); table.Columns.Add(COL); table.Rows.Add(row); row[COL] = list; Console.WriteLine("table created"); object resultObj = table.Rows[0][COL]; Console.WriteLine("resultObj: " + resultObj); ArrayList resultList = (ArrayList)resultObj; string resultStr = (string)resultList[0]; Console.WriteLine(resultStr); } }
The second last WriteLine statement prints: "resultObj: System.Collections.ArrayList". I seem to be retrieving the ArrayList as an object, but I'm unable to cast it. Why? Thanks in advance. Cheers, Michael