RayCan

Hello All,

My code below works perfectly when I put it in an ASP.NET application (default.aspx code behind for example), but as soon as I put it in a web part (compile it into an assembly and place it into GAC) I get this error:

"The type specified in the TypeName property of ObjectDataSource"

ObjectDataSource objDataSrc = new ObjectDataSource("Fully qualified name of my type", "select method name");

objDataSrc.SelectParameters.Add("Perosnid", "123");

GridView grdViewPersons = new GridView();

grdViewPersons.AutoGenerateColumns = false;

grdViewPersons.DataSource = objDataSrc;

grdViewPersons.DataBind();

this.form1.Controls.Add(grdViewPersons);

First of all, both assemblies (web part and my BLL assembly which objectdatasource calls into) are installed into CAG.

Secondly, If I don¡¯t use objectdatasoure and directly call into the BLL, web part works fine , it just does not work with objectDatasource. I know that objectdatasourcer uses reflection to find the select method in the assembly (my BLL), so there should be a problem around the reflection when both assemblies are placed into the GAC

Any help would be appreciated.

Thanks



Re: SharePoint - Development and Programming ObjectDataSource in a web part?

Mart Muller

Hi,

Can you specify on which line of code the error returns The last line will probably not work:

this.form1.Controls.Add(grdViewPersons);

Can you change it to:

this.Controls.Add(grdViewPersons);

Thing is, 'this' is the webpart, which is already a control on the Page. The webpart probably does not have a 'from1'.

I hope this helps

- Mart






Re: SharePoint - Development and Programming ObjectDataSource in a web part?

RayCan

Sorry , in the web part I had already changed the this.form1.Controls.Add(grdViewPersons); to this.Controls.Add(grdViewPersons);. That's not a problem.

I guess probelm is the reflection that datasourceobject uses in order to bind itself to my BLL and its select method. It seems when both web part and BLL are installed in the CAG this reflection does not work. I have strongly named all the assemblies and added them to the safecontrol tag of my web.config.

The thing is, when I do NOT use the objectdatasource by directly calling into my BLL , web part works fine , but when I try to bind the GridView or FormView to the objectdatasource I get these errors . It says the type "my assembly" can not be found.Strange!!!!!

Thanks for your reply though





Re: SharePoint - Development and Programming ObjectDataSource in a web part?

acuze

I have a similar problem. I have a objectdatasource that has a DataObjectTypeName that points to a object thats within a GAC assembly. When i run the code to update the objectdatasource. I get the following error below. If i place this GAC assembly in my web bin directory, the code works. Any help is appreciated. Thanks in advance

System.InvalidOperationException: The data object type specified in the DataObjectTypeName property of ObjectDataSource 'ObjectDataSource_LinkDetails' could not be found.
at System.Web.UI.WebControls.ObjectDataSourceView.TryGetDataObjectType()
at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteUpdate(IDictionary keys, IDictionary values, IDictionary oldValues)
at System.Web.UI.DataSourceView.Update(IDictionary keys, IDictionary values, IDictionary oldValues, DataSourceViewOperationCall





Re: SharePoint - Development and Programming ObjectDataSource in a web part?

RayCan

acuze,

I was never able to find the problem. I just directly called into my BLL layer and get the datatable and bound it to my controls. One thing I have learnt from this forum is that questions of this kind would never get an answer, I regret to say.

Good luck





Re: SharePoint - Development and Programming ObjectDataSource in a web part?

acuze

Actually i have a little workaround which won't help me though.

You can add a reference to the gac assembly in the webconfig file. But since i'm using a in-house framework i don't have the ability to modify the webconfig file to add my assembly. Does anyone know a way to reference my dll.

I currently have a objectdatasource that just updates a object. my page also adds and deletes these object but i don't use the objectdatasource to do this and it works fine which is of course at compile time. So i know my web app can has a reference to the dll in the gac. BUT for some reason the ObjectDataSource doesn't since its during run-time i'm assuming. Sounds like the objectdatasource is a little inefficient. Maybe i'm attacking the problem wrong. Let me know what you think..thanks





Re: SharePoint - Development and Programming ObjectDataSource in a web part?

acuze

I found a work around that might help you but not me. You can modify the web.config file to add a reference to the dll in the gac. I can't do this since i'm using a web.config thats from a in-house framework and i'm not allowed to update it.

I have a objectdatasource that its only job is to select and update a object is compiled in a dll in the gac. My page also add and deletes this object but it doesn't use the objectdatasource and it works fine. Does anyone know a way to make this work. I know 2 workarounds that i've found. One is the one i mentioned in the beginning of the message, the other is to have a copy of the gac dll in your web/ bin directory. Sounds inefficient though. Does anyone know what i'm talking about. Seems like the objectdatasource is inefficient when dealing w/ run-time objects.





Re: SharePoint - Development and Programming ObjectDataSource in a web part?

RayCan

what do you mean by : You can modify the web.config file to add a reference to the dll in the gac

Do you mean defining the object datasource in web.config and referecing it in DLLs placed in the GAC

Thanks





Re: SharePoint - Development and Programming ObjectDataSource in a web part?

RayCan

Actually it worked! fantastic,,

I just added my BLL assembly to the assemblies of web.config and objectdatasource worked like a charm.Thanks for your help man.