在写NHibernate的时候,遇到了:
未能加载文件或程序集“NHibernateDemoWebSite”或它的某一个依赖项。系统找不到指定的文件
以下是错误提示代码:
1
行 31: // .AddDirectory(new System.IO.DirectoryInfo(HostingEnvironment.MapPath("~/App_Data/")));
2
行 32:
3
行 33: config = new NHibernate.Cfg.Configuration().AddAssembly("NHibernateDemoWebSite");
4
行 34:
5
行 35: //.SetDefaultAssembly(typeof(TUserInfo).Assembly.FullName)
6
7
堆栈跟踪:
8
9
10
[FileNotFoundException: 未能加载文件或程序集“NHibernateDemoWebSite”或它的某一个依赖项。系统找不到指定的文件。]
11
System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
12
System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +211
13
System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +141
14
System.Reflection.Assembly.Load(String assemblyString) +25
15
NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +62
16
17
[MappingException: Could not add assembly NHibernateDemoWebSite]
18
NHibernate.Cfg.Configuration.LogAndThrow(MappingException me) +38
19
NHibernate.Cfg.Configuration.AddAssembly(String assemblyName) +116
20
DataAccessFactory..cctor() in e:\学习\Net\NHibernateDemoWebSite\App_Code\DataAccessFactory.cs:33
21
22
[TypeInitializationException: “DataAccessFactory”的类型初始值设定项引发异常。]
23
_Default.Page_Load(Object sender, EventArgs e) in e:\学习\Net\NHibernateDemoWebSite\Default.aspx.cs:21
24
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
25
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
26
System.Web.UI.Control.OnLoad(EventArgs e) +99
27
System.Web.UI.Control.LoadRecursive() +47
28
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
29
30
以下是我写的一部分代码:
DataAccessFactory.cs
1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Web;
5
using System.Web.Security;
6
using System.Web.Hosting;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Web.UI.WebControls.WebParts;
10
using System.Web.UI.HtmlControls;
11
using NHibernate;
12
using NHibernate.Cfg;
13
using NHibernateDemoWebSite;
14
15
/**//// <summary>
16
/// DataAccessFactory 的摘要说明
17
/// </summary>18
public class DataAccessFactory : HttpApplication
19

{
20
21
public static readonly NHibernate.Cfg.Configuration config;
22
public static readonly NHibernate.ISessionFactory sessionFactory;
23
24
static DataAccessFactory()
25
{
26
//log4net.Config.XmlConfigurator.Configure();
27
//config = new NHibernate.Cfg.Configuration();
28
//Console.Write(typeof(TUserInfo).Assembly.FullName);
29
//config.SetDefaultAssembly(typeof(TUserInfo).Assembly.FullName)
30
// .SetDefaultNamespace(typeof(TUserInfo).Namespace)
31
// .AddDirectory(new System.IO.DirectoryInfo(HostingEnvironment.MapPath("~/App_Data/")));
32
33
config = new NHibernate.Cfg.Configuration().AddAssembly("NHibernateDemoWebSite");
34
35
//.SetDefaultAssembly(typeof(TUserInfo).Assembly.FullName)
36
//.SetDefaultNamespace(typeof(TUserInfo).Namespace)
37
//.AddDirectory(new System.IO.DirectoryInfo(HostingEnvironment.MapPath("~/App_Code")));
38
39
//config = new NHibernate.Cfg.Configuration()
40
// .SetDefaultAssembly(typeof(Item).Assembly.FullName)
41
// .SetDefaultNamespace(typeof(Item).Namespace)
42
// .AddDirectory(new DirectoryInfo(HostingEnvironment.MapPath("~/App_Data/")));
43
44
sessionFactory = config.BuildSessionFactory();
45
}
46
47
public static ISession GetCurrenSession()
48
{
49
return sessionFactory.GetCurrentSession();
50
}
51
}
52
注:
注释部分是NHibernate源码里的Demo,我按照他的做法,但是还是出现了这样的问题
以下是实体类:
1
//TUserInfo.cs
2
3
using System;
4
using System.Collections;
5
using System.Web.UI.WebControls;
6
7
namespace NHibernateDemoWebSite
8

{
9
TUserInfo#region TUserInfo
10
11
/**//// <summary>
12
/// TUserInfo object for NHibernate mapped table 'T_UserInfo'.
13
/// </summary>
14
public class TUserInfo : System.IComparable
15
{
16
Member Variables#region Member Variables
17
18
protected int _id;
19
protected string _fUserPassWord;
20
protected string _fCPPassWord;
21
protected string _fUserTrueName;
22
protected string _fIDCard;
23
protected byte _fSex;
24
protected DateTime _fBrithday;
25
protected string _fEmail;
26
protected string _fMobile;
27
protected string _fTelephone;
28
protected string _fQQ;
29
protected string _fcode;
30
protected string _fCardProvince;
31
protected string _fCardCity;
32
protected string _fAddress;
33
protected string _fIcon;
34
protected string _fQuestion;
35
protected string _fAnswer;
36
protected string _fGetPwdNum;
37
protected byte _fisRight;
38
protected DateTime _fLastGetPassWordTime;
39
protected int _fGetPassWordNum;
40
protected string _fip;
41
protected int _floginTimes;
42
protected decimal _fAmount;
43
protected decimal _fAmountFreeze;
44
protected decimal _fAllAmount;
45
protected string _fcardBankType;
46
protected string _fCardName;
47
protected string _fCardAccount;
48
protected int _fcredit;
49
protected string _fRank;
50
protected byte _fUserType;
51
protected byte _fUserTypeState;
52
protected string _fUserTypeImageUrl;
53
protected byte _fStatus;
54
protected string _fisActive;
55
protected DateTime _fregtime;
56
protected DateTime _flastlogintime;
57
protected static String _sortExpression = "Id";
58
protected static SortDirection _sortDirection = SortDirection.Ascending;
59
60
#endregion
61
62
Constructors#region Constructors
63
64
public TUserInfo()
{ }
65
66
public TUserInfo(int id, string fUserPassWord, string fCPPassWord, string fUserTrueName, string fIDCard, byte fSex, DateTime fBrithday, string fEmail, string fMobile, string fTelephone, string fQQ, string fcode, string fCardProvince, string fCardCity, string fAddress, string fIcon, string fQuestion, string fAnswer, string fGetPwdNum, byte fisRight, DateTime fLastGetPassWordTime, int fGetPassWordNum, string fip, int floginTimes, decimal fAmount, decimal fAmountFreeze, decimal fAllAmount, string fcardBankType, string fCardName, string fCardAccount, int fcredit, string fRank, byte fUserType, byte fUserTypeState, string fUserTypeImageUrl, byte fStatus, string fisActive, DateTime fregtime, DateTime flastlogintime)
67
{
68
this._id = id;
69
this._fUserPassWord = fUserPassWord;
70
this._fCPPassWord = fCPPassWord;
71
this._fUserTrueName = fUserTrueName;
72
this._fIDCard = fIDCard;
73
this._fSex = fSex;
74
this._fBrithday = fBrithday;
75
this._fEmail = fEmail;
76
this._fMobile = fMobile;
77
this._fTelephone = fTelephone;
78
this._fQQ = fQQ;
79
this._fcode = fcode;
80
this._fCardProvince = fCardProvince;
81
this._fCardCity = fCardCity;
82
this._fAddress = fAddress;
83
this._fIcon = fIcon;
84
this._fQuestion = fQuestion;
85
this._fAnswer = fAnswer;
86
this._fGetPwdNum = fGetPwdNum;
87
this._fisRight = fisRight;
88
this._fLastGetPassWordTime = fLastGetPassWordTime;
89
this._fGetPassWordNum = fGetPassWordNum;
90
this._fip = fip;
91
this._floginTimes = floginTimes;
92
this._fAmount = fAmount;
93
this._fAmountFreeze = fAmountFreeze;
94
this._fAllAmount = fAllAmount;
95
this._fcardBankType = fcardBankType;
96
this._fCardName = fCardName;
97
this._fCardAccount = fCardAccount;
98
this._fcredit = fcredit;
99
this._fRank = fRank;
100
this._fUserType = fUserType;
101
this._fUserTypeState = fUserTypeState;
102
this._fUserTypeImageUrl = fUserTypeImageUrl;
103
this._fStatus = fStatus;
104
this._fisActive = fisActive;
105
this._fregtime = fregtime;
106
this._flastlogintime = flastlogintime;
107
}
108
109
#endregion
110
111
Public Properties#region Public Properties
112
113
public int Id
114
{
115
get
{ return _id; }
116
set
117
{
118
this._id = value;
119
}
120
}
121
122
public string FUserPassWord
123
{
124
get
{ return _fUserPassWord; }
125
set
126
{
127
if (value != null && value.Length > 50)
128
throw new ArgumentOutOfRangeException("Invalid value for FUserPassWord", value, value.ToString());
129
_fUserPassWord = value;
130
}
131
}
132
133
public string FCPPassWord
134
{
135
get
{ return _fCPPassWord; }
136
set
137
{
138
if (value != null && value.Length > 50)
139
throw new ArgumentOutOfRangeException("Invalid value for FCPPassWord", value, value.ToString());
140
_fCPPassWord = value;
141
}
142
}
143
144
public string FUserTrueName
145
{
146
get
{ return _fUserTrueName; }
147
set
148
{
149
if (value != null && value.Length > 50)
150
throw new ArgumentOutOfRangeException("Invalid value for FUserTrueName", value, value.ToString());
151
_fUserTrueName = value;
152
}
153
}
154
155
public string FIDCard
156
{
157
get
{ return _fIDCard; }
158
set
159
{
160
if (value != null && value.Length > 50)
161
throw new ArgumentOutOfRangeException("Invalid value for FIDCard", value, value.ToString());
162
_fIDCard = value;
163
}
164
}
165
166
public byte FSex
167
{
168
get
{ return _fSex; }
169
set
{ _fSex = value; }
170
}
171
172
public DateTime FBrithday
173
{
174
get
{ return _fBrithday; }
175
set
{ _fBrithday = value; }
176
}
177
178
public string FEmail
179
{
180
get
{ return _fEmail; }
181
set
182
{
183
if (value != null && value.Length > 50)
184
throw new ArgumentOutOfRangeException("Invalid value for FEmail", value, value.ToString());
185
_fEmail = value;
186
}
187
}
188
189
public string FMobile
190
{
191
get
{ return _fMobile; }
192
set
193
{
194
if (value != null && value.Length > 20)
195
throw new ArgumentOutOfRangeException("Invalid value for FMobile", value, value.ToString());
196
_fMobile = value;
197
}
198
}
199
200
public string FTelephone
201
{
202
get
{ return _fTelephone; }
203
set
204
{
205
if (value != null && value.Length > 20)
206
throw new ArgumentOutOfRangeException("Invalid value for FTelephone", value, value.ToString());
207
_fTelephone = value;
208
}
209
}
210
211
public string FQQ
212
{
213
get
{ return _fQQ; }
214
set
215
{
216
if (value != null && value.Length > 20)
217
throw new ArgumentOutOfRangeException("Invalid value for FQQ", value, value.ToString());
218
_fQQ = value;
219
}
220
}
221
222
public string Fcode
223
{
224
get
{ return _fcode; }
225
set
226
{
227
if (value != null && value.Length > 10)
228
throw new ArgumentOutOfRangeException("Invalid value for Fcode", value, value.ToString());
229
_fcode = value;
230
}
231
}
232
233
public string FCardProvince
234
{
235
get
{ return _fCardProvince; }
236
set
237
{
238
if (value != null && value.Length > 50)
239
throw new ArgumentOutOfRangeException("Invalid value for FCardProvince", value, value.ToString());
240
_fCardProvince = value;
241
}
242
}
243
244
public string FCardCity
245
{
246
get
{ return _fCardCity; }
247
set
248
{
249
if (value != null && value.Length > 50)
250
throw new ArgumentOutOfRangeException("Invalid value for FCardCity", value, value.ToString());
251
_fCardCity = value;
252
}
253
}
254
255
public string FAddress
256
{
257
get
{ return _fAddress; }
258
set
259
{
260
if (value != null && value.Length > 100)
261
throw new ArgumentOutOfRangeException("Invalid value for FAddress", value, value.ToString());
262
_fAddress = value;
263
}
264
}
265
266
public string FIcon
267
{
268
get
{ return _fIcon; }
269
set
270
{
271
if (value != null && value.Length > 100)
272
throw new ArgumentOutOfRangeException("Invalid value for FIcon", value, value.ToString());
273
_fIcon = value;
274
}
275
}
276
277
public string FQuestion
278
{
279
get
{ return _fQuestion; }
280
set
281
{
282
if (value != null && value.Length > 100)
283
throw new ArgumentOutOfRangeException("Invalid value for FQuestion", value, value.ToString());
284
_fQuestion = value;
285
}
286
}
287
288
public string FAnswer
289
{
290
get
{ return _fAnswer; }
291
set
292
{
293
if (value != null && value.Length > 100)
294
throw new ArgumentOutOfRangeException("Invalid value for FAnswer", value, value.ToString());
295
_fAnswer = value;
296
}
297
}
298
299
public string FGetPwdNum
300
{
301
get
{ return _fGetPwdNum; }
302
set
303
{
304
if (value != null && value.Length > 100)
305
throw new ArgumentOutOfRangeException("Invalid value for FGetPwdNum", value, value.ToString());
306
_fGetPwdNum = value;
307
}
308
}
309
310
public byte FisRight
311
{
312
get
{ return _fisRight; }
313
set
{ _fisRight = value; }
314
}
315
316
public DateTime FLastGetPassWordTime
317
{
318
get
{ return _fLastGetPassWordTime; }
319
set
{ _fLastGetPassWordTime = value; }
320
}
321
322
public int FGetPassWordNum
323
{
324
get
{ return _fGetPassWordNum; }
325
set
{ _fGetPassWordNum = value; }
326
}
327
328
public string Fip
329
{
330
get
{ return _fip; }
331
set
332
{
333
if (value != null && value.Length > 100)
334
throw new ArgumentOutOfRangeException("Invalid value for Fip", value, value.ToString());
335
_fip = value;
336
}
337
}
338
339
public int FloginTimes
340
{
341
get
{ return _floginTimes; }
342
set
{ _floginTimes = value; }
343
}
344
345
public decimal FAmount
346
{
347
get
{ return _fAmount; }
348
set
{ _fAmount = value; }
349
}
350
351
public decimal FAmountFreeze
352
{
353
get
{ return _fAmountFreeze; }
354
set
{ _fAmountFreeze = value; }
355
}
356
357
public decimal FAllAmount
358
{
359
get
{ return _fAllAmount; }
360
set
{ _fAllAmount = value; }
361
}
362
363
public string FcardBankType
364
{
365
get
{ return _fcardBankType; }
366
set
367
{
368
if (value != null && value.Length > 10)
369
throw new ArgumentOutOfRangeException("Invalid value for FcardBankType", value, value.ToString());
370
_fcardBankType = value;
371
}
372
}
373
374
public string FCardName
375
{
376
get
{ return _fCardName; }
377
set
378
{
379
if (value != null && value.Length > 50)
380
throw new ArgumentOutOfRangeException("Invalid value for FCardName", value, value.ToString());
381
_fCardName = value;
382
}
383
}
384
385
public string FCardAccount
386
{
387
get
{ return _fCardAccount; }
388
set
389
{
390
if (value != null && value.Length > 100)
391
throw new ArgumentOutOfRangeException("Invalid value for FCardAccount", value, value.ToString());
392
_fCardAccount = value;
393
}
394
}
395
396
public int Fcredit
397
{
398
get
{ return _fcredit; }
399
set
{ _fcredit = value; }
400
}
401
402
public string FRank
403
{
404
get
{ return _fRank; }
405
set
406
{
407
if (value != null && value.Length > 20)
408
throw new ArgumentOutOfRangeException("Invalid value for FRank", value, value.ToString());
409
_fRank = value;
410
}
411
}
412
413
public byte FUserType
414
{
415
get
{ return _fUserType; }
416
set
{ _fUserType = value; }
417
}
418
419
public byte FUserTypeState
420
{
421
get
{ return _fUserTypeState; }
422
set
{ _fUserTypeState = value; }
423
}
424
425
public string FUserTypeImageUrl
426
{
427
get
{ return _fUserTypeImageUrl; }
428
set
429
{
430
if (value != null && value.Length > 100)
431
throw new ArgumentOutOfRangeException("Invalid value for FUserTypeImageUrl", value, value.ToString());
432
_fUserTypeImageUrl = value;
433
}
434
}
435
436
public byte FStatus
437
{
438
get
{ return _fStatus; }
439
set
{ _fStatus = value; }
440
}
441
442
public string FisActive
443
{
444
get
{ return _fisActive; }
445
set
446
{
447
if (value != null && value.Length > 100)
448
throw new ArgumentOutOfRangeException("Invalid value for FisActive", value, value.ToString());
449
_fisActive = value;
450
}
451
}
452
453
public DateTime Fregtime
454
{
455
get
{ return _fregtime; }
456
set
{ _fregtime = value; }
457
}
458
459
public DateTime Flastlogintime
460
{
461
get
{ return _flastlogintime; }
462
set
{ _flastlogintime = value; }
463
}
464
465
public static String SortExpression
466
{
467
get
{ return _sortExpression; }
468
set
{ _sortExpression = value; }
469
}
470
471
public static SortDirection SortDirection
472
{
473
get
{ return _sortDirection; }
474
set
{ _sortDirection = value; }
475
}
476
#endregion
477
478
IComparable Methods#region IComparable Methods
479
public int CompareTo(object obj)
480
{
481
if (!(obj is TUserInfo))
482
throw new InvalidCastException("This object is not of type TUserInfo");
483
484
int relativeValue;
485
switch (SortExpression)
486
{
487
case "Id":
488
relativeValue = this.Id.CompareTo(((TUserInfo)obj).Id);
489
break;
490
case "FUserPassWord":
491
relativeValue = (this.FUserPassWord != null) ? this.FUserPassWord.CompareTo(((TUserInfo)obj).FUserPassWord) : -1;
492
break;
493
case "FCPPassWord":
494
relativeValue = this.FCPPassWord.CompareTo(((TUserInfo)obj).FCPPassWord);
495
break;
496
case "FUserTrueName":
497
relativeValue = (this.FUserTrueName != null) ? this.FUserTrueName.CompareTo(((TUserInfo)obj).FUserTrueName) : -1;
498
break;
499
case "FIDCard":
500
relativeValue = (this.FIDCard != null) ? this.FIDCard.CompareTo(((TUserInfo)obj).FIDCard) : -1;
501
break;
502
case "FSex":
503
relativeValue = (this.FSex != null) ? this.FSex.CompareTo(((TUserInfo)obj).FSex) : -1;
504
break;
505
case "FBrithday":
506
relativeValue = (this.FBrithday != null) ? this.FBrithday.CompareTo(((TUserInfo)obj).FBrithday) : -1;
507
break;
508
case "FEmail":
509
relativeValue = (this.FEmail != null) ? this.FEmail.CompareTo(((TUserInfo)obj).FEmail) : -1;
510
break;
511
case "FMobile":
512
relativeValue = (this.FMobile != null) ? this.FMobile.CompareTo(((TUserInfo)obj).FMobile) : -1;
513
break;
514
case "FTelephone":
515
relativeValue = (this.FTelephone != null) ? this.FTelephone.CompareTo(((TUserInfo)obj).FTelephone) : -1;
516
break;
517
case "FQQ":
518
relativeValue = (this.FQQ != null) ? this.FQQ.CompareTo(((TUserInfo)obj).FQQ) : -1;
519
break;
520
case "Fcode":
521
relativeValue = (this.Fcode != null) ? this.Fcode.CompareTo(((TUserInfo)obj).Fcode) : -1;
522
break;
523
case "FCardProvince":
524
relativeValue = (this.FCardProvince != null) ? this.FCardProvince.CompareTo(((TUserInfo)obj).FCardProvince) : -1;
525
break;
526
case "FCardCity":
527
relativeValue = (this.FCardCity != null) ? this.FCardCity.CompareTo(((TUserInfo)obj).FCardCity) : -1;
528
break;
529
case "FAddress":
530
relativeValue = (this.FAddress != null) ? this.FAddress.CompareTo(((TUserInfo)obj).FAddress) : -1;
531
break;
532
case "FIcon":
533
relativeValue = (this.FIcon != null) ? this.FIcon.CompareTo(((TUserInfo)obj).FIcon) : -1;
534
break;
535
case "FQuestion":
536
relativeValue = (this.FQuestion != null) ? this.FQuestion.CompareTo(((TUserInfo)obj).FQuestion) : -1;
537
break;
538
case "FAnswer":
539
relativeValue = (this.FAnswer != null) ? this.FAnswer.CompareTo(((TUserInfo)obj).FAnswer) : -1;
540
break;
541
case "FGetPwdNum":
542
relativeValue = (this.FGetPwdNum != null) ? this.FGetPwdNum.CompareTo(((TUserInfo)obj).FGetPwdNum) : -1;
543
break;
544
case "FisRight":
545
relativeValue = (this.FisRight != null) ? this.FisRight.CompareTo(((TUserInfo)obj).FisRight) : -1;
546
break;
547
case "FLastGetPassWordTime":
548
relativeValue = (this.FLastGetPassWordTime != null) ? this.FLastGetPassWordTime.CompareTo(((TUserInfo)obj).FLastGetPassWordTime) : -1;
549
break;
550
case "FGetPassWordNum":
551
relativeValue = (this.FGetPassWordNum != null) ? this.FGetPassWordNum.CompareTo(((TUserInfo)obj).FGetPassWordNum) : -1;
552
break;
553
case "Fip":
554
relativeValue = (this.Fip != null) ? this.Fip.CompareTo(((TUserInfo)obj).Fip) : -1;
555
break;
556
case "FloginTimes":
557
relativeValue = (this.FloginTimes != null) ? this.FloginTimes.CompareTo(((TUserInfo)obj).FloginTimes) : -1;
558
break;
559
case "FAmount":
560
relativeValue = (this.FAmount != null) ? this.FAmount.CompareTo(((TUserInfo)obj).FAmount) : -1;
561
break;
562
case "FAmountFreeze":
563
relativeValue = (this.FAmountFreeze != null) ? this.FAmountFreeze.CompareTo(((TUserInfo)obj).FAmountFreeze) : -1;
564
break;
565
case "FAllAmount":
566
relativeValue = (this.FAllAmount != null) ? this.FAllAmount.CompareTo(((TUserInfo)obj).FAllAmount) : -1;
567
break;
568
case "FcardBankType":
569
relativeValue = (this.FcardBankType != null) ? this.FcardBankType.CompareTo(((TUserInfo)obj).FcardBankType) : -1;
570
break;
571
case "FCardName":
572
relativeValue = (this.FCardName != null) ? this.FCardName.CompareTo(((TUserInfo)obj).FCardName) : -1;
573
break;
574
case "FCardAccount":
575
relativeValue = (this.FCardAccount != null) ? this.FCardAccount.CompareTo(((TUserInfo)obj).FCardAccount) : -1;
576
break;
577
case "Fcredit":
578
relativeValue = (this.Fcredit != null) ? this.Fcredit.CompareTo(((TUserInfo)obj).Fcredit) : -1;
579
break;
580
case "FRank":
581
relativeValue = (this.FRank != null) ? this.FRank.CompareTo(((TUserInfo)obj).FRank) : -1;
582
break;
583
case "FUserType":
584
relativeValue = (this.FUserType != null) ? this.FUserType.CompareTo(((TUserInfo)obj).FUserType) : -1;
585
break;
586
case "FUserTypeState":
587
relativeValue = (this.FUserTypeState != null) ? this.FUserTypeState.CompareTo(((TUserInfo)obj).FUserTypeState) : -1;
588
break;
589
case "FUserTypeImageUrl":
590
relativeValue = (this.FUserTypeImageUrl != null) ? this.FUserTypeImageUrl.CompareTo(((TUserInfo)obj).FUserTypeImageUrl) : -1;
591
break;
592
case "FStatus":
593
relativeValue = (this.FStatus != null) ? this.FStatus.CompareTo(((TUserInfo)obj).FStatus) : -1;
594
break;
595
case "FisActive":
596
relativeValue = (this.FisActive != null) ? this.FisActive.CompareTo(((TUserInfo)obj).FisActive) : -1;
597
break;
598
case "Fregtime":
599
relativeValue = (this.Fregtime != null) ? this.Fregtime.CompareTo(((TUserInfo)obj).Fregtime) : -1;
600
break;
601
case "Flastlogintime":
602
relativeValue = (this.Flastlogintime != null) ? this.Flastlogintime.CompareTo(((TUserInfo)obj).Flastlogintime) : -1;
603
break;
604
default:
605
goto case "Id";
606
}
607
if (TUserInfo.SortDirection == SortDirection.Ascending)
608
relativeValue *= -1;
609
return relativeValue;
610
}
611
#endregion
612
}
613
614
#endregion
615
}
616
映射文件:
1
<!--TUserInfo.hbm.xml-->
2
<?xml version="1.0" encoding="utf-8" ?>
3
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
4
<class name="NHibernateDemoWebSite.TUserInfo, NHibernateDemoWebSite" table="T_UserInfo">
5
<id name="Id" type="Int32" unsaved-value="null">
6
<column name="FuserID" length="4" sql-type="int" not-null="true" index="PK_T_USERINFO"/>
7
<column name="FUserLoginName" length="50" sql-type="varchar" not-null="true" index="PK_T_USERINFO"/>
8
<generator class="native" />
9
</id>
10
<property name="FUserPassWord" type="String">
11
<column name="FUserPassWord" length="50" sql-type="varchar" not-null="false"/>
12
</property>
13
<property name="FCPPassWord" type="String">
14
<column name="FCPPassWord" length="50" sql-type="varchar" not-null="true"/>
15
</property>
16
<property name="FUserTrueName" type="String">
17
<column name="FUserTrueName" length="50" sql-type="varchar" not-null="false"/>
18
</property>
19
<property name="FIDCard" type="String">
20
<column name="FIDCard" length="50" sql-type="varchar" not-null="false"/>
21
</property>
22
<property name="FSex" type="Byte">
23
<column name="FSex" length="1" sql-type="tinyint" not-null="false"/>
24
</property>
25
<property name="FBrithday" type="DateTime">
26
<column name="FBrithday" length="8" sql-type="datetime" not-null="false"/>
27
</property>
28
<property name="FEmail" type="String">
29
<column name="FEmail" length="50" sql-type="varchar" not-null="false"/>
30
</property>
31
<property name="FMobile" type="String">
32
<column name="FMobile" length="20" sql-type="varchar" not-null="false"/>
33
</property>
34
<property name="FTelephone" type="String">
35
<column name="FTelephone" length="20" sql-type="varchar" not-null="false"/>
36
</property>
37
<property name="FQQ" type="String">
38
<column name="FQQ" length="20" sql-type="varchar" not-null="false"/>
39
</property>
40
<property name="Fcode" type="String">
41
<column name="Fcode" length="10" sql-type="nvarchar" not-null="false"/>
42
</property>
43
<property name="FCardProvince" type="String">
44
<column name="FCardProvince" length="50" sql-type="varchar" not-null="false"/>
45
</property>
46
<property name="FCardCity" type="String">
47
<column name="FCardCity" length="50" sql-type="varchar" not-null="false"/>
48
</property>
49
<property name="FAddress" type="String">
50
<column name="FAddress" length="100" sql-type="varchar" not-null="false"/>
51
</property>
52
<property name="FIcon" type="String">
53
<column name="FIcon" length="100" sql-type="varchar" not-null="false"/>
54
</property>
55
<property name="FQuestion" type="String">
56
<column name="FQuestion" length="100" sql-type="varchar" not-null="false"/>
57
</property>
58
<property name="FAnswer" type="String">
59
<column name="FAnswer" length="100" sql-type="varchar" not-null="false"/>
60
</property>
61
<property name="FGetPwdNum" type="String">
62
<column name="FGetPwdNum" length="100" sql-type="varchar" not-null="false"/>
63
</property>
64
<property name="FisRight" type="Byte">
65
<column name="FisRight" length="1" sql-type="tinyint" not-null="false"/>
66
</property>
67
<property name="FLastGetPassWordTime" type="DateTime">
68
<column name="FLastGetPassWordTime" length="8" sql-type="datetime" not-null="false"/>
69
</property>
70
<property name="FGetPassWordNum" type="Int32">
71
<column name="FGetPassWordNum" length="4" sql-type="int" not-null="false"/>
72
</property>
73
<property name="Fip" type="String">
74
<column name="Fip" length="100" sql-type="nvarchar" not-null="false"/>
75
</property>
76
<property name="FloginTimes" type="Int32">
77
<column name="FloginTimes" length="4" sql-type="int" not-null="false"/>
78
</property>
79
<property name="FAmount" type="Decimal">
80
<column name="FAmount" length="8" sql-type="money" not-null="false"/>
81
</property>
82
<property name="FAmountFreeze" type="Decimal">
83
<column name="FAmountFreeze" length="8" sql-type="money" not-null="false"/>
84
</property>
85
<property name="FAllAmount" type="Decimal">
86
<column name="FAllAmount" length="8" sql-type="money" not-null="false"/>
87
</property>
88
<property name="FcardBankType" type="String">
89
<column name="FcardBankType" length="10" sql-type="varchar" not-null="false"/>
90
</property>
91
<property name="FCardName" type="String">
92
<column name="FCardName" length="50" sql-type="varchar" not-null="false"/>
93
</property>
94
<property name="FCardAccount" type="String">
95
<column name="FCardAccount" length="100" sql-type="varchar" not-null="false"/>
96
</property>
97
<property name="Fcredit" type="Int32">
98
<column name="Fcredit" length="4" sql-type="int" not-null="false"/>
99
</property>
100
<property name="FRank" type="String">
101
<column name="FRank" length="20" sql-type="varchar" not-null="false"/>
102
</property>
103
<property name="FUserType" type="Byte">
104
<column name="FUserType" length="1" sql-type="tinyint" not-null="false"/>
105
</property>
106
<property name="FUserTypeState" type="Byte">
107
<column name="FUserTypeState" length="1" sql-type="tinyint" not-null="false"/>
108
</property>
109
<property name="FUserTypeImageUrl" type="String">
110
<column name="FUserTypeImageUrl" length="100" sql-type="varchar" not-null="false"/>
111
</property>
112
<property name="FStatus" type="Byte">
113
<column name="FStatus" length="1" sql-type="tinyint" not-null="false"/>
114
</property>
115
<property name="FisActive" type="String">
116
<column name="FisActive" length="100" sql-type="varchar" not-null="false"/>
117
</property>
118
<property name="Fregtime" type="DateTime">
119
<column name="Fregtime" length="8" sql-type="datetime" not-null="false"/>
120
</property>
121
<property name="Flastlogintime" type="DateTime">
122
<column name="Flastlogintime" length="8" sql-type="datetime" not-null="false"/>
123
</property>
124
</class>
125
</hibernate-mapping>
126
Feedback
未能加载文件或程序集.这不是很明显吗?你的程序集放的不是地方,调整一下位置。
@Sunshine
那你可以告诉怎么放吗?我都试过很多次了!!
DataAccessFactory 在app_code文件夹下
可以试试
Assembly a = Assembly.Load("__code");