Trying to produce my first sample with Dynamic LINQ and I just can't seem to get it to work. Here's what I've got. NBL It's a bit rugged because I've been culling it back trying to find the problem.
Dim blah = (New dcDataContext).Employees.Where("AccountGUID=#1", accountId)
The error I am getting is:
Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.RuntimeModule.GetTypes(RuntimeModule module) +0
System.Reflection.RuntimeModule.GetTypes() +4
System.Reflection.Assembly.GetTypes() +70
System.Linq.Dynamic.DefaultDynamicLinqCustomTypeProvider.<FindTypesMarkedWithAttribute>b__0(Assembly x) +38
System.Linq.<SelectManyIterator>d__14`2.MoveNext() +234
System.Linq.WhereEnumerableIterator`1.MoveNext() +152
System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other) +82
System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer) +125
System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection) +50
System.Linq.Dynamic.DefaultDynamicLinqCustomTypeProvider.GetCustomTypes() +81
System.Linq.Dynamic.ExpressionParser.CreateKeywords() +532
System.Linq.Dynamic.ExpressionParser..ctor(ParameterExpression[] parameters, String expression, Object[] values) +66
System.Linq.Dynamic.DynamicExpression.ParseLambda(ParameterExpression[] parameters, Type resultType, String expression, Object[] values) +72
System.Linq.Dynamic.DynamicExpression.ParseLambda(Type itType, Type resultType, String expression, Object[] values) +132
System.Linq.Dynamic.DynamicQueryable.Where(IQueryable source, String predicate, Object[] args) +252
System.Linq.Dynamic.DynamicQueryable.Where(IQueryable`1 source, String predicate, Object[] args) +51
TimeClock.Linq.Filters.Employees.QueryableExtensions.FromAccount(IQueryable`1 source, Guid accountId) in C:\Visual Studio Projects\mtc
tc
.login.Page_Load(Object sender, EventArgs e) in C:\Visual Studio Projects\mtc\tc\login.aspx.vb:13
System.Web.UI.Control.OnLoad(EventArgs e) +92
System.Web.UI.Control.LoadRecursive() +54
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
You should write it like this:
Dim blah = (New dcDataContext).Employees.Where("AccountGUID=#0", accountId)
refer:
This is completely weird but here's what I did (trying to fix something else) and now it works. I set full access permissions to 'Everyone' on the folder C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
Related
In the below code the SelectedUser is null; I expected to the code below throw an null exception which I can handle somewhere in my code for example:
Application.Current.DispatcherUnhandledException += this.DispatcherUnhandledException;
or
AppDomain.CurrentDomain.UnhandledException += this.CurrentDomainUnhandledException;
// Code example; here is the SelectedUser null.
this.IsUserInRole = this.SelectedUser.UserRole;
Unfortunately, the null exception is caught in the method” MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)” and never thrown it again.
I think this is a bug in the .Net library; I cannot find any useful information in the net about the problem. Any help will be appreciated!
Used Technologies:
Windows 7 x64
.Net Framework 4.5
Visual Studio 2012 Update 2
Underlayer:
WPF
Entity Framework
SQL Server 2012
Call Stack:
Cannot get 'IsUserInRole' value (type 'Boolean') from '' (type 'DataGridViewModel'). BindingExpression:Path=IsUserInRole; DataItem='DataGridViewModel' (HashCode=22143992); target element is 'CheckBox' (Name=''); target property is 'IsChecked' (type 'Nullable`1') TargetInvocationException:'System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
...UserInterface.Settings.DataGridViewModel.get_IsUserInRole() in …….\SettingsModule\UserSettingsView\DataGridViewModel.cs:line 521
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at MS.Internal.Data.PropertyPathWorker.GetValue(Object item, Int32 level)
at MS.Internal.Data.PropertyPathWorker.RawValue(Int32 k)'
Thanks
Looks like the exception is swalled by WPF which is done by design.
More on this here:
Why does WPF databinding swallow exceptions?
On our production environment users are unable to register.
They receive: An error has occurred. Error: User Registration is currently unavailable.
The stacktrace is:
DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Entities.Users.ProfilePropertyAccess.DisplayDataType(ProfilePropertyDefinition definition) at DotNetNuke.Entities.Users.ProfilePropertyAccess.GetRichValue(ProfilePropertyDefinition prop, String strFormat, CultureInfo formatProvider) at DotNetNuke.Entities.Users.ProfilePropertyAccess.GetProperty(String strPropertyName, String strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope currentScope, Boolean& PropertyNotFound) at DotNetNuke.Services.Tokens.BaseCustomTokenReplace.replacedTokenValue(String strObjectName, String strPropertyName, String strFormat) at DotNetNuke.Services.Tokens.BaseTokenReplace.ReplaceTokens(String strSourceText) at DotNetNuke.Services.Localization.Localization.GetSystemMessage(String strLanguage, PortalSettings objPortal, String MessageName, UserInfo objUser, String ResourceFile, ArrayList CustomArray, IDictionary CustomDictionary, String CustomCaption, Int32 AccessingUserID) at DotNetNuke.Services.Mail.Mail.SendMail(UserInfo user, MessageType msgType, PortalSettings settings) at DotNetNuke.Entities.Modules.UserModuleBase.CompleteUserCreation(UserCreateStatus createStatus, UserInfo newUser, Boolean notify, Boolean register) at DotNetNuke.Modules.Admin.Users.ManageUsers.UserCreateCompleted(Object sender, UserCreatedEventArgs e)
I suspect there is a profile property definition missing. I'm wondering how to fix this error?
It turns out my ProfilePropertyDefinition table DataType column values do not match EntryID values from the Lists table.
select * from profilePropertyDefinition
compared to
select * from Lists
where Listname = 'DataType'
order by EntryID
I figured this out by
Noticing users are actually added
Then I looked at a working dnn install's profile property page. Compared to the broken one.
The broken one was missing the data type field.
The original question is :
Unit Testing an Html Helper with AutoFixture
Not sure I should re-open the original question; however since I marked the original question as resolved I decided to create a new one. Apologies if I did this wrong.
I was using Mark’s suggested approach but I got stuck while using the Freeze.
Below is the complete source code…
Class Under Test:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace MvcDemo2.Helpers
{
public static class Keys
{
public static readonly string SomeKey = "SomeKey";
}
public static class SampleHelpers
{
public static MvcHtmlString SampleTable(this HtmlHelper helper,
SampleModel model, IDictionary<string, object> htmlAttributes)
{
if (helper == null)
{
throw new ArgumentNullException("helper");
}
if (model == null)
{
throw new ArgumentNullException("model");
}
TagBuilder tagBuilder = new TagBuilder("table");
tagBuilder.MergeAttributes(htmlAttributes);
tagBuilder.GenerateId(helper.ViewContext.
HttpContext.Items[Keys.SomeKey].ToString());
return MvcHtmlString.Create(
tagBuilder.ToString(TagRenderMode.Normal));
}
}
}
public class SampleModel
{
}
}
Unit Test is to ensure the Html returned as expected for the specified key within HttpContext
public void SampleTableHtmlHelper_WhenKeyExistWithinHttpContext_ReturnsExpectedHtml()
I configured the Fixture as below
var fixture = new Fixture().Customize(new AutoMoqCustomization());
Then the Freeze on ViewContext:
var vc = fixture.Freeze<ViewContext>();
I get the below exception:
Error 1 Test
'MvcDemo2.Tests.Controllers.SampleHelpersTestsAutoFixture.SampleTableHtmlHelper_WhenKeyExistWithinHttpContext_ReturnsExpectedHtml'
failed: System.Reflection.TargetInvocationException : Exception has
been thrown by the target of an invocation.
---- System.NotImplementedException : The method or operation is not
implemented. at
System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo
method, Object target, Object[] arguments, SignatureStruct& sig,
MethodAttributes methodAttributes, RuntimeType typeOwner) at
System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method,
Object target, Object[] arguments, Signature sig, MethodAttributes
methodAttributes, RuntimeType typeOwner) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
Boolean skipVisibilityChecks) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object
value, BindingFlags invokeAttr, Binder binder, Object[] index,
CultureInfo culture) at
System.Reflection.RuntimePropertyInfo.SetValue(Object obj, Object
value, Object[] index) at
Ploeh.AutoFixture.Kernel.AutoPropertiesCommand1.Execute(T specimen,
ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request,
ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.<>c__DisplayClass6.b__1(ISpecimenBuilder
b) at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.d__a51.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1
source) at
Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object
request, ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request,
ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.SpecimenContext.Resolve(Object request) at
Ploeh.AutoFixture.Kernel.SeedIgnoringRelay.Create(Object request,
ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.<>c__DisplayClass6.b__1(ISpecimenBuilder
b) at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.d__a51.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1
source) at
Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object
request, ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.Postprocessor1.Create(Object request,
ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.<>c__DisplayClass6.<Create>b__1(ISpecimenBuilder
b) at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext()
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Linq.Enumerable.<DefaultIfEmptyIterator>d__a51.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1
source) at
Ploeh.AutoFixture.Kernel.CompositeSpecimenBuilder.Create(Object
request, ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.RecursionGuard.Create(Object request,
ISpecimenContext context) at
Ploeh.AutoFixture.Kernel.SpecimenContext.Resolve(Object request) at
Ploeh.AutoFixture.SpecimenFactory.CreateAnonymous[T](ISpecimenContext
context, T seed) at
Ploeh.AutoFixture.SpecimenFactory.CreateAnonymous[T](ISpecimenBuilderComposer
composer, T seed) at
Ploeh.AutoFixture.FixtureFreezer.Freeze[T](IFixture fixture, T seed)
at
MvcDemo2.Tests.Controllers.SampleHelpersTestsAutoFixture.SampleTableHtmlHelper_WhenKeyExistWithinHttpContext_ReturnsExpectedHtml()
in C:\Users\...:line 78
----- Inner Stack Trace ----- at
System.Web.HttpContextBase.get_Items() at
System.Web.Mvc.ViewContext.ScopeCache.Get(IDictionary2 scope,
HttpContextBase httpContext) at
System.Web.Mvc.ViewContext.SetClientValidationEnabled(Boolean enabled,
IDictionary`2 scope, HttpContextBase httpContext) at
System.Web.Mvc.ViewContext.set_ClientValidationEnabled(Boolean
value) C:\Users... 78
Seems it fails on when it try to set the value of property
ViewContext.SetClientValidationEnabled.
I’m stuck on this. Any thoughts greatly appreciated.
Well, if you consider the inner stack trace you'll notice that the exception is being thrown by HttpContextBase.Items. If you were to look at the implementation using a reflection tool you would find that this virtual method throws a NotImplementedException - talk about a POLA violation. A lot of the Web abstractions in the BCL does exactly that, which is really, really painful to deal with.
I'm not sure it'll help you further on, but you can get past this particular issue by turning off AutoProperties for the ViewContext class like this:
fixture.Customize<ViewContext>(c => c.OmitAutoProperties());
Thanks Mark. I find AutoFixture is very useful but when I Unit Test MVC, I find bit trickier to apply the API. It is probably because I’m still new to the API.
With….
fixture.Customize<ViewContext>(c => c.OmitAutoProperties());
var vc = fixture.Freeze<ViewContext>();
The above works fine, but as you suspected it fails again when I try to add items to
vc.HttpContext.Items.Add(Keys.SomeKey, "foo");
Exceptiion: The method or operation is not implemented.
The reflector on HttpContextBase...
public virtual IDictionary Items
{
get
{
throw new NotImplementedException();
}
}
So the only way I can think is to create my own implementation of HttpContextBase
private class FakeHttpContext : HttpContextBase
{
private Dictionary<object, object> _items = new Dictionary<object, object>();
public override IDictionary Items { get { return _items; } }
}
Then below is the confusing bit..
fixture.Inject<HttpContextBase>(new FakeHttpContext());
var hc = fixture.CreateAnonymous<HttpContextBase>();
If I swap these two lines (which creates the anonymouse instance first and then inject the fake instance) causes the error..
AutoFixture was unable to create an instance from
System.Web.HttpContextBase, most likely because it has no public
constructor.
So far I can come up with a test like this...
public void SampleTableHtmlHelper_WhenKeyExistWithinHttpContext_ReturnsExpectedHtml()
{
//Arrange
var fixture = new Fixture();
fixture.Customize<ViewContext>(c => c.OmitAutoProperties());
var vc = fixture.Freeze<ViewContext>();
fixture.Inject<HttpContextBase>(new FakeHttpContext());
var hc = fixture.CreateAnonymous<HttpContextBase>();
vc.HttpContext = hc;
vc.HttpContext.Items.Add(Keys.SomeKey, "foo");
var htmlHelper = fixture.CreateAnonymous<HtmlHelper>();
var sampleModel = fixture.CreateAnonymous<SampleModel>();
//Act
var result = SampleHelpers.SampleTable(htmlHelper, sampleModel, null).ToString();
//Assert
Assert.Equal("<table id=\"foo\"></table>", result);
}
Also removed new AutoMoqCustomization() as it seems to have no effect on the test.
Once I get more familiar with AutoFixture I might be able to come up with a better version. Thanks for the help.
Seems it fails on when it try to set the value of property ViewContext.SetClientValidationEnabled.
That problem was fixed for me by this answer, see how he gets an HtmlHelper (see also here).
Object of type 'System.Collections.Generic.List`1[Jud.Itd.Cmis.BusinessObjects.AddressType]' cannot be converted to type 'System.Collections.Generic.IList`1[Jud.Itd.Cmis.BusinessObjects.AddressType]'.
Closing Visual Studio and reopening and recompiling all fixes it, so I would say that this is clearly a bug and a huge nuisance.
The question is, is there a work around other than restarting VS or living without the Designer? Cleaning the app and recompiling all doesn't do it.
Instances of this error (1)
1. Hide Call Stack
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck, Boolean doCheckConsistency)
at System.Reflection.RtFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean doVisibilityCheck)
at System.Runtime.Serialization.SerializationFieldInfo.InternalSetValue(Object obj, Object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, Boolean requiresAccessCheck, Boolean isBinderDefault)
at System.Runtime.Serialization.FormatterServices.SerializationSetValue(MemberInfo fi, Object target, Object value)
at System.Runtime.Serialization.ObjectManager.CompleteObject(ObjectHolder holder, Boolean bObjectFullyComplete)
at System.Runtime.Serialization.ObjectManager.DoNewlyRegisteredObjectFixups(ObjectHolder holder)
at System.Runtime.Serialization.ObjectManager.RegisterObject(Object obj, Int64 objectID, SerializationInfo info, Int64 idOfContainingObj, MemberInfo member, Int32[] arrayIndex)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.RegisterObject(Object obj, ParseRecord pr, ParseRecord objectPr, Boolean bIsString)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.ParseObjectEnd(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Parse(ParseRecord pr)
at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
at System.Resources.ResXDataNode.GenerateObjectFromDataNodeInfo(DataNodeInfo dataNodeInfo, ITypeResolutionService typeResolver)
at System.Resources.ResXDataNode.GetValue(ITypeResolutionService typeResolver)
at System.Resources.ResXResourceReader.ParseDataNode(XmlTextReader reader, Boolean isMetaData)
at System.Resources.ResXResourceReader.ParseXml(XmlTextReader reader)
Help with this error
MSDN Help
Forum posts about this error
Search the MSDN Forums for posts related to this error
I might have an answer. I just encountered the same error and I found out that this is produced if there are some errors in a Form constructor or the Form_Load() method. I tried to comment out code in these methods and when it didn't helped I realized that there must be en error in some component.
And it was. If you use some custom component and it have some properties set to null even after a constructor of this component is called it could cause this rendering error.
You can find these properties in your Form.resx file. They will have value in the Value column set to (Nothing/null).
What helped me was to delete these bad lines there and mark my properties with the following attributes.
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
The WinForm Designer has a bug. In fact, this bug rates as the most complained about bug in WinForm development. Live with it.
I'm working on a project where entities are being decorated by NHibernate mapping attributes such as [Property] and [Class]. Unfortunately RIAServices doesn't seem to support most of these attributes, which causes a failure when RIAServices is trying to generate the Silverlight Client Code.
When I try to build a DomainService that uses an entity decorated with the [Class] or [Property] attribute, I get an ArgumentNullException with the following error message:
Error 2 The "CreateRiaClientFilesTask" task failed unexpectedly.
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: TypeName
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)
at System.Type.GetType(String typeName)
at NHibernate.Mapping.Attributes.ClassAttribute.get_NameType()
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
at System.Web.DomainServices.Tools.StandardCustomAttributeBuilder.GetPropertyValues(IEnumerable`1 propertyMaps, Attribute attribute)
at System.Web.DomainServices.Tools.StandardCustomAttributeBuilder.GetAttributeDeclaration(Attribute attribute)
at System.Web.DomainServices.Tools.CustomAttributeGenerator.GenerateCustomAttributes(ClientProxyGenerator proxyGenerator, CodeTypeDeclaration referencingType, IEnumerable`1 attributes, CodeCommentStatementCollection comments)
at System.Web.DomainServices.Tools.CustomAttributeGenerator.GenerateCustomAttributes(ClientProxyGenerator proxyGenerator, CodeTypeDeclaration referencingType, IEnumerable`1 attributes, CodeAttributeDeclarationCollection outputCollection, CodeCommentStatementCollection comments)
at System.Web.DomainServices.Tools.EntityProxyGenerator.Generate()
at System.Web.DomainServices.Tools.ClientProxyGenerator.GenerateProxyClass(String& generatedCode)
at System.Web.DomainServices.Tools.CreateRiaClientFilesTask.GenerateClientProxies()
at System.Web.DomainServices.Tools.CreateRiaClientFilesTask.Execute()
at Microsoft.Build.Framework.ITask.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteInstantiatedTask(EngineProxy engineProxy, ItemBucket bucket, TaskExecutionMode howToExecuteTask, ITask task, Boolean& taskResult) SL
I know that using Fluent NHibernate should solve the problem because it removes the need for NHibernate dependencies, but I want to make sure first that there aren't any other solutions before moving to Fluent NHibernate. Any thoughts on solving this problem?
As I mentioned in the comments it sounds like the issue is with NHibernate throwing up during the code generation. If you really want to use the attributes I would suggest getting the NHibernate source code and trying to attach the VS debugger to the VS instance that is doing the code generation, might help you figure out why it is failing.
Probably a better approach would be to follow this post by Brada on using NHibernate with RIA Services or watching this screencast on NHibernate with RIA Services. Both of those places seem to have working examples of them working together, so maybe start there instead of going down the route you're going.
You can add preprocessor directives to your entities so that when compiled for silverlight the attributes are missing.
#if SILVERLIGHT
//nothing
#else
[class]
#endif
public class entity{
}
We had the same issue. Solution: Get rid of the attributes and just use XML for mapping.