Unhandled ORMEntityValidationException problem

Posts   
 
    
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 01-Oct-2008 17:13:43   

I seem to be having the same problem described here:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8108&HighLight=1

I am using Dependency Injection validator -- code taken from the LLBLgen manual. The validation code works, except the exception it throws is not being caught.

This seems impossible to me, but there it is.

This test passes:

[TestMethod()] public void ValidateQuestionBeforeSaveTest4() { var adapter = new DataAccessAdapter(); var question = new QuestionEntity();

        try
        {
            adapter.SaveEntity(question);
        }
        catch (ORMEntityValidationException e)
        {
            Assert.AreEqual("Answer must be specified", e.Message);
        }
    }

If I run the test in debug mode the exception is NOT caught (I get a popup inside the Validator code), although the execution proceeds into the catch block as though it had been caught.

Same thing when I run this in a Console app. The exception throws up a dialog box as if there was no try/catch, and then proceeds into the catch anyway.

Edit:

Did some more searching on the forum here. As per this thread:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=4339&HighLight=1

if I disable Just My Code the problem goes away.

This doesn't seem like the right solution though...

I am using VS.Net 2008 and LLBLgen 2.6

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Oct-2008 17:45:41   

if I disable Just My Code the problem goes away.

What do you mean by this?

Which LLBLGen Pro runtime library version are you using? Did you install VS 2008 SP1? Did you install .NET Framework 3.5 SP1?

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 01-Oct-2008 18:14:43   

Which LLBLGen Pro runtime library version are you using?

v2.0.50727

Did you install VS 2008 SP1?

Yes

Did you install .NET Framework 3.5 SP1?

Yes

In the VS.Net settings for debugging you can enable/disable the "Just My Code" feature. It is enabled by default. When I disable it the problem goes away.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Oct-2008 18:47:08   

v2.0.50727

That's not the correct RTL version number. Please check this: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=7725

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Oct-2008 00:18:06   

RTL from SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll is 2.6.8.624

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Oct-2008 12:08:35   

RTL from SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll is 2.6.8.624

That's somehow old. Just to be sure, would you please use the latest release of the RTL?

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Oct-2008 15:40:15   

Updated to RTL 2.6.8.911

Switched "Just My Code" back on again (VS.Net Default setting)

The problem is now back. ORMValidationException thrown by injected Validator is not caught properly in a standard try/catch block.

Disabling "Just My Code" makes the problem disappear again.

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Oct-2008 17:16:29   

Would you please attach a simple Northwind repro solution?

csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 02-Oct-2008 17:25:06   

Walaa wrote:

Would you please attach a simple Northwind repro solution?

This isn't super-urgent any longer since I have the "Just My Code" workaround.

I don't have time to do a Northwind solution right now. I can send the entire solution itself, since it is a relatively small proof-of-concept anyhow. It is 5.5 Mb zipped, including a backup of the db.

Otherwise I can do a NW on the weekend...

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 02-Oct-2008 17:51:02   

It's ok, please send the zipped solution to the following e-mails:

support AT LLBLGen DOT com walaa DOT atef AT LLBLGen DOT com

Remove the objs & bin folders (only leave any 3rd party dlls needed for rebuilding the solution) to decrease the total size of the package.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 03-Oct-2008 12:40:39   

There's no DB in the .zip file you sent so I can't test anything.

That said, the exception not being caught could be caused by vs.net triggering such an event through watch/local windows in the debugger. The call then comes from another thread, which might even have loaded a shadow copy of the ormsupportclasses dll which IMHO could lead to an exception being sent to the handler but which originates from another assembly INSTANCE, so the 'Type' is different (different assembly instance as different appdomain) and therefore the exception isn't caught.

I don't have another explanation for it, the code should catch the exception which apparently isn't caught. What you could do is to add another catch clause with Exception below it and check whether the type of the exception (get it with GetType()) is indeed equal to ORMEntityValidationException and if a difference is caused by a different assembly instance.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 03-Oct-2008 13:51:49   

Walaa sent me the DB. The QuestionBase table in the DB has no 'Category' field, so I couldn't test your code (which didn't came with a solution file either). Did you sent an older DB?

Could you please create a simple repro project for us with working db? thanks.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 03-Oct-2008 18:23:36   

Received new database, switched on 'Just My Code' -> can't reproduce it. Also with Just My Code switched off I can't reproduce it: exception is caught properly in the routine which should... I have all debug windows open. (VS.NET 2008 SP1)

Frans Bouma | Lead developer LLBLGen Pro
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 03-Oct-2008 18:26:32   

Otis wrote:

Received new database, switched on 'Just My Code' -> can't reproduce it. Also with Just My Code switched off I can't reproduce it.

I guess I can take a screencam of it happening. Also from other threads it seems other people had the same issue...

Probably some strange config issue in VS or .Net

In any case it definitely happens on my laptop. Will test same solution on a different machine to see if it happens there.

Just saw this as we are going through this issue:

Also, with VSTS 2010, Microsoft has made a significant investment in testing features and simplified tools required to integrate testing across the life cycle, Mendlen said. New features include the ability to eliminate non-reproducible bugs by providing a TiVo-like recording capability for reproducing bugs.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 04-Oct-2008 07:36:16   

Well, to be clear: that an exception of type T isn't caught by a catch which catches type T is never our fault, that can only be due to some weird vs.net shadow appdomain issue.

I also can't reproduce it no matter what I do. Also, I suggested some things to check in this post: http://www.llblgen.com/tinyforum/GotoMessage.aspx?MessageID=80359&ThreadID=14404 higher up in this thread. Please check that in your own code. Also please check if you have 'watch' elements open. We didn't use resharper/coderush etc. during testing, as issues related to those tools are obviously out of our scope.

Frans Bouma | Lead developer LLBLGen Pro
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 04-Oct-2008 16:29:25   

Otis wrote:

Well, to be clear: that an exception of type T isn't caught by a catch which catches type T is never our fault, that can only be due to some weird vs.net shadow appdomain issue.

Well I doubt this is your "fault" and in any case I am only looking to help since others seem to have encountered this, and probably have encountered it in other contexts unrelated to LLBLgen.

Not sure if this matters, but when I change the catch to only catch a plain Exception the problem still exists.

For now I have worked around this issue. Will try the same code on some other machines this weekend and let you know if I can find a common denominator (e.g., could be ReSharper...)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 05-Oct-2008 12:06:42   

So the exception isn't catchable at all? Hmm... that's really strange. You do have Sp1 installed?

Frans Bouma | Lead developer LLBLGen Pro
csmac3144
User
Posts: 74
Joined: 12-Sep-2007
# Posted on: 05-Oct-2008 16:37:39   

Otis wrote:

So the exception isn't catchable at all? Hmm... that's really strange. You do have Sp1 installed?

It seemed very strange to me as well.

Yes I have .Net and VS SP1 installed.

The other things installed are:

  • ReSharpter (latest)
  • AnkhSVN (latest)
  • SharePoint extenstions 1.2

That's about it. Vista Business 32bit, SP1

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39863
Joined: 17-Aug-2003
# Posted on: 06-Oct-2008 10:54:48   

We can't repro it. Please post back in this thread if you have more info. We also believe that vs.net is the problem here.

Frans Bouma | Lead developer LLBLGen Pro