473,786 Members | 2,344 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ObjectDataSourc e, DataObjectTypeN ame and '...could not find a non-generic method ...'

Hi Everyone,
This Saturday the stage was set. The problem simply could not go on
existing -- it had to be solved. Many hours, articles, compilations
and frustrations later I still did not find an answer. Even pacing
around my flat until I nearly went into an altered state of reality
proved futile.

So here is the problem...

When I link up the ObjectDataSourc e UpdateMethod to a method in the
TypeName class that takes individual parameters (using
'<UpdateParamet ers... </UpdateParameter s>') all is well. Eg.

<asp:ObjectData Source ID="ObjectDataS ource1"
Runat="server"
EnableCaching=" false"
TypeName="Recip eToolUI.Materia lComponent"
SelectMethod="G etMaterials"
UpdateMethod="U pdateMaterial"
OldValuesParame terFormatString ="{0}"
<UpdateParamete rs>
<%-- just a lot of prameters --%>
</UpdateParameter s>
</asp:ObjectDataS ource>

When I try to link up a method that takes an object (using
DataObjectTypeN ame) instead of individual value types like this:

...
DataObjectTypeN ame='RecipeTool .Material'
...

I keep on getting this error:
"""
ObjectDataSourc e 'ObjectDataSour ce1' could not find a non-generic
method 'UpdateMaterial ' that takes parameters of type
'RecipeTool.Mat erial'.
"""

Things I have tried (besides the pacing):
0. Using only VS 2005 to link things up.

1. Adding attributes to the UpdateMethod method in the
DataObjectTypeN ame class, as well as to the class itself.

This only resulted in VS seeing the method (in the ObjectDataSourc e
configuration wizard), but it does not solve the problem.

2. Tried various method signatures.

3. Deleted the Asp.Net temporary files.

4. Changed namespaces, method names, class names. This proved that
the compiler/runtime can find the class, but not the method.

Any suggestions or help will be greatly appreciated.

Regards.

Sep 3 '07 #1
9 8847
Are you using OldValuesParame terFormatString ?

If so, are you providing a method
RecipeToolUI.Ma terialComponent .UpdateMaterial which takes both old and
new values?
Sep 3 '07 #2
On Sep 3, 11:04 pm, Muhammad Naveed Yaseen <mnyas...@gmail .comwrote:
Are you using OldValuesParame terFormatString ?

If so, are you providing a method
RecipeToolUI.Ma terialComponent .UpdateMaterial which takes both old and
new values?
Hi, thanks for responding hey!

I have used OldValuesParame terFormatString ="{0}", and left it out
completely, while specifying ConflictDetecti on="OverwriteCh anges".
This should cause the runtime to request a function taking a single
object argument (that specified in DataObjectTypeN ame) as parameter.

I have also tried setting OldValuesParame terFormatString ="{0}", and
leaving it out, while setting ConflictDetecti on="CompareAllV alues" and
then I also provided (in addition to the single object parameter
method) a method taking two objects (just as the docs say, one for the
old, one for the new values).

It seems to me as if the way the runtime looks up methods when you
specify DataObjectTypeN ame, as apposed to when you provide
'<UpdateParamet ers... </UpdateParameter s>' differ.
I have also noticed the following. When trying to configure the
ObjectDataSourc e in VS, two entries for the business objects appear in
the dropdown lists (eg. when selecting what object the
ObjectDataSourc e must use for the TypeName, there are two entries for
RecipeTool.Mate rial, and all the other objects in namespace
RecipeTool).

Could it be due to two versions of everything in RecipeTool being
visible to the runtime, and that for some reason, using
DataObjectTypeN ame (as apposed to specifying UpdateParameter s) makes
the ObjectDataSourc e choose the wrong DataObjectTypeN ame to look for
while trying to identify the right method to call in class specified
by TypeName?

In other words, the 'public void UpdateMaterial (Material m)' method
in the TypeName class 'MaterialCompon ent' use one version of the
'Material' class, while the ObjectDataSourc e's DataObjectTypeN ame
refers to another version of the 'Material' class?

How can I check this? How can I remove the extra classes (that might
be causing the problem)?

Thanks in advance again!

Sep 3 '07 #3

Have you ensured that

1) The type 'RecipeTool.Mat erial' is constructible without parameter
(i.e. it's default public parameterless contructor isn't suppressed by
presence of parameter constructors or private parameterless
constructor)

2) The type 'RecipeTool.Mat erial' has matching public get-set
properties for all fields with exact spelling match

3) If InsertMethod or DeleteMethod are being called, those are also
using same type (RecipeTool.Mat erial)

4) The methods SelectMethod, InsertMethod and DeleteMethod are public
and either,,,

a) static
b) OR public parameterless constructor is not suppressed by presence
of parameter constructors or private parameterless constructor.
c) OR an object instance provided in ObjectCreating event

If it is still not working with these conditions being true, I would
be keen to look into the code. Kindly post here or drop at
mn******@gmail. com
Regarding the two types you are seeing in VS, if the leading
namespaces before these two types are same, then that is not a
problem. Sometimes VS does pick up same type more than once during
recursion. However if leading namespaces are different then that is
not right.

Sep 4 '07 #4
On Sep 4, 7:27 am, Muhammad Naveed Yaseen <mnyas...@gmail .comwrote:
Have you ensured that

1) The type 'RecipeTool.Mat erial' is constructible without parameter
(i.e. it's default public parameterless contructor isn't suppressed by
presence of parameter constructors or private parameterless
constructor)

2) The type 'RecipeTool.Mat erial' has matching public get-set
properties for all fields with exact spelling match

3) If InsertMethod or DeleteMethod are being called, those are also
using same type (RecipeTool.Mat erial)

4) The methods SelectMethod, InsertMethod and DeleteMethod are public
and either,,,

a) static
b) OR public parameterless constructor is not suppressed by presence
of parameter constructors or private parameterless constructor.
c) OR an object instance provided in ObjectCreating event

If it is still not working with these conditions being true, I would
be keen to look into the code. Kindly post here or drop at
mnyas...@gmail. com

Regarding the two types you are seeing in VS, if the leading
namespaces before these two types are same, then that is not a
problem. Sometimes VS does pick up same type more than once during
recursion. However if leading namespaces are different then that is
not right.
Hi Muhammad,
Thanks again for your help, I really appreciate it. It would be hard
to give you relevant code samples short of giving you the whole
project because things are tied up a bit.

I have carefully confirmed that all of the above assertions are true.
While reading through a sample of what I want to do, I saw that the
sample place the TypeName class in the App_Code folder, while mine is
in a folder just off the root of the project.

After placing It in App_Code I got an error I had long before (which I
solved back then by taking the code out of App_Code):

"Unable to cast object of type 'RecipeTool.Log ic.Material' to type
'RecipeTool.Log ic.Material'.".

(I added the 'Logic' namespace a bit earlier, placing all the logic
classes there, but it could just as well not be there -- does not
influence anything.)
This error is thrown from within the method I could not get at before,
(the UpdateMethod), but now the SelectMethod also throws this error at
spots where I try to cast from objects returned by NHibernate -- a
kind of ORM library I am using. Note that the SelectMethod and
UpdateMethod (with value type parameters) both work fine while the
class they are in is not in App_Code.

I strongly suspect there being two versions of Material, but how can I
remove the one?

Sep 4 '07 #5
One possible place where shadow copy of a type may exist is asp.net
compiler cache (usually C:\windows\Micr osoft.NET\Frame work
\v2.0.50727\Tem porary ASP.NET Files).

If I would be in this situation I would have proceeded like following.

1) Ensure that type 'RecipeTool.Log ic.Material' has public scope and
not internal (i.e. ***public*** class Material,,, instead of class
Material)

2) Delete contents of C:\windows\Micr osoft.NET\Frame work
\v2.0.50727\Tem porary ASP.NET Files (may have to stop IIS or restart
computer to delete contents)

3) Now compile again and see if we still get the error.

4) If still getting error, then take the grid and object to a new
temporary working solution (remove all dependancies, as purpose here
is not make it 100% in temporary solution but to find out which
component is causing shadow copy)

5) After ensuring simple most version is working in temporary
solution, would add other components to this solution, and after each
addition see if it is still working. Wherever it stop working, that
component may be the culprit (perhaps an undetected cricular
reference, or too deeply nested types/controls)
Sep 4 '07 #6
On Sep 4, 6:51 pm, Muhammad Naveed Yaseen <mnyas...@gmail .comwrote:
One possible place where shadow copy of a type may exist is asp.net
compiler cache (usually C:\windows\Micr osoft.NET\Frame work
\v2.0.50727\Tem porary ASP.NET Files).

If I would be in this situation I would have proceeded like following.

1) Ensure that type 'RecipeTool.Log ic.Material' has public scope and
not internal (i.e. ***public*** class Material,,, instead of class
Material)

2) Delete contents of C:\windows\Micr osoft.NET\Frame work
\v2.0.50727\Tem porary ASP.NET Files (may have to stop IIS or restart
computer to delete contents)

3) Now compile again and see if we still get the error.

4) If still getting error, then take the grid and object to a new
temporary working solution (remove all dependancies, as purpose here
is not make it 100% in temporary solution but to find out which
component is causing shadow copy)

5) After ensuring simple most version is working in temporary
solution, would add other components to this solution, and after each
addition see if it is still working. Wherever it stop working, that
component may be the culprit (perhaps an undetected cricular
reference, or too deeply nested types/controls)
I tried deleting the temp files before but will give it a go again,
thanks.
>From some debug printouts at the point where the cast fails I saw that
the two objects came from different assemblies.
The one instanciated from within code in App_Code came from a
'App_Code.asdfs d' assembly, and the one loaded from the NHibernate
classes (called in App_Code, but through the NHibernate classes)
belonged to the proper 'RecipeTool' assembly -- will post the details
later -- so I can understand why they can't be casted.

Now my question is how to force code to use the proper 'RecipeTool'
assembly instead of the `on-the-fly` generated assemblies... I would
really like to know which VS solution template to use for what
situation or, better still, how to compile things by use of the
command line tools, or the msbuild tools so that one can have a solid
control of what is compiled and where.

There is a reason why tools like Ant exists: building anything larger
than a couple of files becomes complicated. Have seen NAnt, which I
assume to be a .Net port of Ant?

Sep 4 '07 #7
On Sep 5, 3:30 am, Muhammad Naveed Yaseen <mnyas...@gmail .comwrote:
Following links may be useful for manual compilation.

http://msdn2.microsoft.com/en-us/lib...1/11/3415.aspx
Good news!! I think I found a solution!

At the point where the cast failed, I managed to get debug output (by
printing 'typeof(Materia l).AssemblyQual ifiedName' and 'q.List()
[0].GetType().Asse mblyQualifiedNa me'):
-----
RecipeTool.Logi c.Material, App_Code.-0vbez6p, Version=0.0.0.0 ,
Culture=neutral , PublicKeyToken= null
RecipeTool.Logi c.Material, RecipeTool, Version=1.0.0.0 ,
Culture=neutral , PublicKeyToken= null
----
(the list 'q' contains the loaded objects)

Then I followed these steps:
created a new "C# Web Application Project"
copied everything relevant in
made sure it compiles
"Build" "Publish RecipeTool"
create a virtual directory there where I just published
brows to that virtual directory

and it works!

Now the debug output gives:
----
RecipeTool.Logi c.Material, RecipeTool, Version=1.0.0.0 ,
Culture=neutral , PublicKeyToken= null
RecipeTool.Logi c.Material, RecipeTool, Version=1.0.0.0 ,
Culture=neutral , PublicKeyToken= null
----

Still need to test if everything is solved now, but it looks like the
ObjectDataSourc e now correctly identifies the UpdateMethod.

Thank you very much for the help man!

Until next problem , all the best.

Sep 5 '07 #9
I, too have been wrestling with this one for quite some time and finally
found a solution last night.

The problem seems to occur when you create a selection statement in the
table adapter that uses more fields than the update statement uses. When you
update, it is still seeking for the parameter that the select statement uses,
even when you have removed all other references to it.

I tried everything I ever found posted online for this one to no avail.
Finally, I ended up building a stored procedure for my update statement, and
here's the key... I included in the stored procedure a reference to the
parameter that was not used, but then I simply did nothing with that
parameter in my update statement. This way, .NET was happy because it passed
the parameter, and the update statement ran okay because it did nothing with
the parameter other than capture it in the stored procedure.

Hopefully this will save someone all the time that it cost me to figure it
out!

--
Tony L
Albuquerque, NM
Oct 2 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2087
by: MTomov | last post by:
Hi fellas, has anyone managed to get ObjectDataSource to work Datasets where the Dataset is used as BusinessEntity class? What I mean is the following architecture: 1.WebPage with ObjectDataSource 2. CustomBusinessObject which * does validation,
3
3553
by: Jeronimo Bertran | last post by:
I have a FormView that shows details of a specific record on a table. The SelecMethod returns a DataSet that includes all the fields from my Event table and other read-only fields from linked tables. My FormView has controls that are bound to the fiuelds on the dataset table. I am now changing the FormView's Default Mode to Edit but I am having problems with the related fields. My ObjectDataSource is defined as: ...
4
1814
by: Joe | last post by:
I need to do a find/replace on a column name in DataColumn.Expression. Is there a way to do the following using RegEx? MyColumn 10 and Desc = "This is MyColumn desc" I need to replace the MyColumn which is not in a quoted string. Thanks, Joe
3
1218
by: 13 | last post by:
Hello list, I have been searching the internet for python version 0.9.0 sources which had been posted to alt.sources list, but without any luck. Maybe someone has it available somewhere ? Thanks, Martins
0
2188
by: GMartin | last post by:
I have a pop-up form with a three columned Grid that has checkboxes in a Template Column in the first/left-most column. (The form is to allow users to select "Members" of a group, where they check or clear the boxes next to the potential members they want to add or remove.) The Object Data Source is as follows... <asp:ObjectDataSource ID="odsMembers" runat="server" SelectMethod="GetGroupMembersSelectList"...
1
3541
by: Allan Ebdrup | last post by:
I have a asp.net v2 website that runs fine on our development server. I have published the website to a stage server and it runs fine, but when I publish it to production I get the following error: The type specified in the TypeName property of ObjectDataSource 'PositionPostingsDataSource' could not be found. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more...
2
1801
by: tawright915 | last post by:
Ok so here is my regex (--.*\n|/\*(.|\n)*?\*/). It finds all comments just fine. However I want it to return to me all strings that are not commented out. Is there a way to exclude the comments and only show the non-commented strings Here is an example of the data that I am working with /* select * from db2 */
2
1475
by: SM | last post by:
Ok, this must be simple but the more i search the more i don't find. It's about SimpleXML and PHP. How to find non-existing nodes or nodes with no text My XML file looks a little bit like this: i.e. 1 <discography> <CD> <title></title>
1
1475
by: SM | last post by:
Ok, this must be simple but the more i search the more i don't find. It's about SimpleXML and PHP. How to find non-existing nodes or nodes with no text My XML file looks a little bit like this: i.e. 1 <discography> <CD> <title></title>
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.