Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding businessobj project to MVC solution
Message
From
16/07/2011 06:36:01
 
 
To
All
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
Adding businessobj project to MVC solution
Miscellaneous
Thread ID:
01518346
Message ID:
01518346
Views:
114
Hello,
I have a business object project that I use in several mm.net web applications. I store my database keys in web.config.
<databases>
    
    <add key="ShortCuts\Connection" value="Provider=vfpoledb.1;Data Source=C:\webcom\data\ShortCuts.dbc"/>
    <add key="ShortCuts\DataAccessClass" value="DataAccessOLEDB"/>
        
  </databases>
All I do is add the business object project to the solution, add a reference to the business object project to the startup project and set a dependency to the business object project.

A sample usage of a business object class in a web form’s method code would consist of:
Assist oAssist = new Assist();
DataSet ds = oAssist.GetAllAssistants();
Then I would bind the dataset in various ways.
I recently started to dabble in Microsoft MVC and was hoping to add my business object project to my MVC solution but I do not think I have everything brought over correctly. First I added my database keys to the solutions web.config.

I additionally placed a
 <configSections>
    <section name="databaseSets" type="System.Configuration.NameValueSectionHandler,           System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
    <section name="databases" type="System.Configuration.NameValueSectionHandler,           System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
  </configSections>
section to web.config so that the compiler does not complain about my database keys.

................

I have a simple MVC solution running with a controller called ShortCutsController.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShortCuts.Models;
using System.Data;
using eCentric.gmg.Business;


namespace ShortCuts.Controllers
{
    public class ShortCutsController : Controller
    {
        
         
      
        // GET: /ShortCuts/
        public void Index()
        {
            Assist oAssist = new Assist();
            DataSet ds = oAssist.GetAllAssistants();
            
            Response.Write("<h2>Coming Soon - ShortCuts Index View</h2>");

                               
        }


        // GET: /ShortCuts/Details/2
        public void Details(int id) 
        {
            Response.Write("<h2>Coming Soon - ShortCuts Details View for record: " + id + " *" +  "</h2> ");
        
        }

    }
}
When I run the line of code:
 Assist oAssist = new Assist();
I get a runtime error, namely:
Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not load type 'ShortCutsBusiness.Assist' from assembly 'ShortCuts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.TypeLoadException: Could not load type 'ShortCutsBusiness.Assist' from assembly 'ShortCuts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

Source Error: 


Line 27: 
Line 28:                                
Line 29:         }
Line 30: 
Line 31: 
 

Source File: d:\mvc\Projects\ShortCuts\Controllers\ShortCutsController.cs    Line: 29 

Stack Trace: 


[TypeLoadException: Could not load type 'ShortCutsBusiness.Assist' from assembly 'ShortCuts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.]
   ShortCuts.Controllers.ShortCutsController.Index() in d:\mvc\Projects\ShortCuts\Controllers\ShortCutsController.cs:29
   lambda_method(Closure , ControllerBase , Object[] ) +62
   System.Web.Mvc.<>c__DisplayClass1.<WrapVoidAction>b__0(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +17
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +199
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
   System.Web.Mvc.<>c__DisplayClassd.<InvokeActionMethodWithFilters>b__a() +56
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +267
   System.Web.Mvc.<>c__DisplayClassf.<InvokeActionMethodWithFilters>b__c() +20
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +190
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +345
   System.Web.Mvc.Controller.ExecuteCore() +115
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +42
   System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) +10
   System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__4() +34
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +21
   System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +12
   System.Web.Mvc.Async.WrappedAsyncResult`1.End() +55
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +43
   System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841105
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184

 


--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 
How do I simulate the mm.net web form startup environment so that I may use the business object project in a Microsoft MVC solution.
Next
Reply
Map
View

Click here to load this message in the networking platform