Friday, April 24, 2009

VS2008: Error while setting the property of a custom web control - An unhandled exception has occurred

You might see this error when you create a custom web control which has a property that you would like to set in the web page that consumes the control.
An unhandled exception has occurred. 'value' could not be set on 'propertyName'

I had created lots of custom controls in VS 2005 and creating custom properties for these controls was pretty straight forward. So I was surprised when i saw this error. I tried various things to find the reason and why the value was not getting set. Finally i gave up and started searching the net and finally got this link
http://www.west-wind.com/Weblog/posts/484172.aspx

this seemed to a bug with VS 2008 and SP1 and till date there is no solution. The only option is to close VS and open it again. But again this is a problem with the IDE, you can still compile the project and run it and it will not throw any compilation error nor show any error while accessing those properties you set on your custom control.

For those who are interested, Rick (whose blog I have referenced above) also has a issue ticket raised with microsoft which is marked as resolved, but the patch mentioned also seems to be buggy (read the comments in the link given below)
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=361826

Comments from the above link

>>>> Hi, I installed the hotfix: KB961847 - "Error creating control- [text] property" ASP.NET server cntls in VS the problem still there? can anyone tell me if i got the wrong hotfix? or is there any hotfix i need to install as well?
Posted by NatureNZ on 4/23/2009 at 2:56 PM

>>>> and the hotfix seems broke the web user control as well, i had a web user control uses standard asp controls and ajax control. it was working well in design time and now it is got the same error again.
Posted by NatureNZ on 4/23/2009 at 3:38 PM

Active directory queries

I had to spend lot of time trying to figure how to write queries on active directory using SSIS. I searched the internet for quite some time with no concrete examples. I did find examples using scripts but none for querying using ADO objects in SSIS. So I thought there might be others like me out there who might need some help .. so here goes

some of the Field names
- givenName = First name of user
- sn = Last name of user
- memberof = list of groups that the user belongs to
- cn = Display name
- objectGUID = Unique value for each record
- samAccountName = windows Login Name

The "FROM" clause would need to contain the complete domain controller name
so if you domain is called "corp.company.us.com", then your from clause would be like this
select field1, field2 from
FROM 'LDAP://DC=corp,DC=commpany,DC=us,DC=us'

if you want to fetch only the users you will need to specify a where clause like WHERE objectClass='user'

I had a requirement where I had to fetch users belonging to a particular group. I had a lot of problem finding this query. I finally learned that your where clause needs to have the whole heirarchy of the group specified. For eg, If you want to find all users in a Group called "Finance" your where clause needs to include

> memberOf = 'CN=Finance,DC=corp,DC=commpany,DC=us,DC=us'

Now if the department is within a Orgnization unit or OU called "AllUsers", then qour query needs to specify that too
> memberOf = 'CN=Finance,OU=AllUsers,DC=corp,DC=commpany,DC=us,DC=us'

Similarly you need to first check how the groups, users are created within your active directory and make changes to your query .. do remember to add the domain controller information too ..

Sample query finding all users within finance group where the finance group is plaed within a OU=Allusers

select cn
FROM 'LDAP://DC=corp,DC=commpany,DC=us,DC=us'
WHERE objectClass='user'
and memberOf = 'CN=Finance,OU=AllUsers,DC=corp,DC=commpany,DC=us,DC=us'

Hope this helps someone out there ..