I'm trying hard to create a way to automate user administration on sharepoint and I got around to produce the following.
SPSite site = new SPSite("http://sharepoint/klantgegevens/" + groupname);
SPWeb web = site.OpenWeb();
SPMember member = null;
SPUser user = null;
bool found = false;
found = SharepointGroupExists(groupname);
for (int index = 0; index < web.Users.Count; index++)
member = web.Users[index];
user = web.Users[index];
web.SiteGroups.Add(groupname,member, user, "");
But there's an exception coming from the web.SiteGroups.Add(..); call. It says Value does not fall in the expected range. Can anybody tell me where I could find more information on this call, especially some information on the exceptions it can throw.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook
Sorry! You can't! .Net dlls are managed code. You know you can call unmanaged code by P/Invoke, but not vice versa. If there is a managed code that you want to use, maybe you could make it a service or a commandline console application, then you can communicate with it from your C++ program.
I've searched some documentation and I was able to do it.
The trick is to register the .Net dll as a COM server.
But to be able to register it as a COM server you must first have a tlb file of it.
This tlb file you can create with the visual studio tool tlbexp.exe.
From the command prompt:
tlbexp dotNET.dll /win32 /out:dotNET.tlb
Once you have the tlb file you can use regasm to register the .Net dll as a COM server. You will not be able to run regasm from the windows command prompt. You must launch the visual studio command prompt to do this.
In the visual studio command prompt type:
regasm dotNET.dll /tlb:dotNET.tlb
From this point you can use the classes and functions of the .Net dll is whatever language that understands COM.
Truely I solute you. I really urge you to write an article about it in CodeProject with more details. Many people will miss this old post. I've allowed myself to bookmark this post for future referal. Really brilliant.
I have the following. A form with a splitcontainer, ie.. panel1 left & panel2 right. On the left panel I have a treeview, as the user selects an item from the treeview I want to display the appropriate form onto the right hand panel.
I tried the following, it compiles but fails at runtime.
A simple way would be to try to instantiate the COM object you intend to use. If this throws a COMException, the component usually simply isn't registered (yet).
But there is no way you can find out which folder a component has to be registered from, that completely depends on the component you want to use.
-- Black holes are the places where God divided by 0...
Last Visit: 31-Dec-99 18:00 Last Update: 8-Aug-22 13:02