ADO.NET :: Hibernate Factory Initialization?
Sep 11, 2010tell me where I could initialize (in the mvc code) the hibernate factory?
View 1 Repliestell me where I could initialize (in the mvc code) the hibernate factory?
View 1 RepliesI'm using Fluent NHibernate and need to get my Connection String from the connection.connection_string property on hibernate.cfg.xml file to create my Session Factory:
private static ISessionFactory SessionFactory {
get {
return = Fluently.Configure()
.Database(MySQLConfiguration.Standard.ConnectionString(c => c.FromConnectionStringWithKey("MyConnStr")))
.Mappings(m => m.FluentMappings.AddFromAssemblyOf<FooMap>())
.ExposeConfiguration(c => c.Properties.Add("hbm2ddl.keywords", "none"))
.BuildSessionFactory();
}
}
I want to replace MyConnStr (that is in my web.config file) "c => c.FromConnectionStringWithKey("MyConnStr")" for the connection string from the hibernate.cfg.xml file.
I've tried use NHibernate.Cfg.Environment.ConnectionString, but it didn't work.
I need to run some code that will fetch some configuration values from the web.config during first run of an asp.net mvc application. These values will not change frequently but that is not my main concern.
One way that I can think of is calling the method in Application_Start() method in the global.asax.cs file,
I've got a piece of code that I want to run one time when my website is first loaded.It is basically a static initialization of another module.Is there some event I can hook into that runs when the site is first served to a client?It doesn't even need to be per session, just on first load to any client.
I'm using vs2010, .net 4.0, asp.net 4.0
I think I know the answer to this but hoping someone has a neat solution. We are currently using two kinds of drop down controls (telerik and .net). I'm hoping to combine these into one control but struggling with a user friendly design.
Ideally the control would be created in the design file with a bool property of say "SimpleBox", to determine which kind of control to inherit. The instantiation would then be generated in the code behind design file and the constructor would then dynamically load the base (which isn't possible). The easy solution would be for me to create a IDropDown interface then have a factory create the correct one. The only real problem with this is the fact the instantiation has to be manually written every time. Which is a hassle, and does not speed up our process at all.
Although it isn't directly possible i'm looking for a solution along the lines of a factory which is ran inside the object constructor for setting the base, based on a bool property.
I have an ASP.NET web-site and a WCF service which is called from ASP. The problem is, that during the first client request the site loads aufully slow, cause some time-consuming static objects are being created inside the WCF service. Is it possible to call any service method (by doing this the wcf object will be created), when the site gets loaded in IIS? (I know there is a solution for this problem in ASP 4 and IIS 7.5, but i'd like to know what's about IIS6-7). It is something like "user emulation") Maybe i can add some event handlers in global.asax?
View 1 Replies I'm writing an MVC app and want to have a central DataBase factory class to provide all my DB connections, something like this:-
[Code]....obviously I'll have to instanciate this every time I need to use it, so I was thinking of making it a static class:-
[Code].... so that instead of my controller code saying
[Code].... I can just say
but would this cause a memory leak? I'm sure I remember reading somewhere that if a static class creates objects that persist beyond it's methods and return those (esp things like DB connection objects) these won't get garbaged collected when the calling method is disposed of as they were created/referenced outside the scope of that calling (controller action) method and so will hang around in memory?
var tableObject = DatabaseFactory.GetDatabaseTable();
List<DbRecord> records = tableObject.Table.ToList();
I am creating a generic list of objects using this syntax:
[Code]....
know what is object declaration and initialization but confused over ojbect instantiation ,i am giving a example below what i understood :
Class ABC
{
Public static Void main()
{
ABC a // Object declaration
a = new ABC(); //Object initialization
[code]...
I am having an Asp.net Web application in .Net 3.5 Framework, deployed on IIS 6.0. Obviously we have used Http Modules in our application. The problem is that we are having many entries specifying the message "Http Module is getting Initialized" Now, I would like to know when does an Http Module get initialized? I mean is there any specific reason? Also, is there any case of recycling of http module?
View 2 RepliesWhen I initialize my client to connect to AppFabric's cache, it seems to inconsistently take up to 30 seconds to connect on the following line:
factory = new DataCacheFactory(configuration);
See full Init() code below - mostly taken from here.I say inconsistently because sometimes it takes 1 second and other times 27, 28 , etc ... seconds. I have an asp.net site using the AppFabric cache - which lives on a different box (on the same domain). Everything is working great, except for the inconsistent connection time. When it connects, its all good - I just need to get it to consistently connect in ~1 second :)
public static void Init()
{
if (cache == null)
{
Stopwatch sw = new Stopwatch();
sw.Start();
[Code]....
We have a silverlight/asp.net application which communicates with WCF to fetch data. Now we are facing a problem where in the silverlight component is taking some time to initialize after the asp.net page life cycle is completed.We have tried tracing all the events and found that there is a time lapse between the aspx page unload event and silverlight initialize event. This we have tried with even a simple application (hello world) but still have found the same result.There is nearly 3-4 seconds delay i.e the silverlight component initialization starts 3-4 seconds after the page unload event ends.
View 1 RepliesI am doing some sorting of an array and in order to achieve that I have to declare bounds of a new array based on amount of results returned. So if I get 2 results I will initialize
tagArray = New Integer() {0, 1}, if 5 then
tagArray = New Integer() {0, 1, 2, 3, 4}. The amount of results is unknown and it can be anywhere from 200 to 500 results returned. Is there a way to simplify this? I could probably hard-code it but that would look ugly.
Our web application started out as a big, honkin' ASP.NET AJAX 'page' with oodles of controls on it. They all shared a small set of large .js and .css files. I need to use some of these controls in other, unrelated pages around our site. The difficulty is in all the other stuff the .css and .js files bring along with them when I try to use those controls elsewhere - too much and there's a lot of bloat, too little and the controls don't work.
So, I've been experimenting with breaking up the .css and .js and writing the controls to register the .js and .css they need. Initially I will end up with many more but smaller .js and .css files, but I can combine them at run-time later. I just want to encapsulate these controls so the pages that use them know less about what it takes to use them.But I am running into a problem. I am using OnInit or OnLoad to register the .css and .js as needed. Unfortunately, none of these methods is called if the control is not visible the first time you hit the page when all the .css and .js needs to make its way to the client. It isn't until later on that the controls are enabled for thier specific functions that they are visible and could emit the .js or .css. Then it's too late!
Do I have to bite the bullet and hand-include the right .css/.js on the pages I use these controls on, or is there a better way to 'inventory' the controls in use to get them to emit what they need?
I've noticed that a request to 'favicon.ico' is being passed to my ASP.net MVC controller factory when using Google Chrome and the Visual Studio Development Server. The 'controllerType' parameter has a value of 'null' which is unsurprisingly resulting in an unhandled exception and which I only know about because of an error log.where the request is coming from and why ASP.net is letting it get to the controller factory? CSS files and images for example are being correctly filtered out.
View 2 RepliesI visited this Link to study about Factory design pattern.http://wiki.asp.net/page.aspx/310/factory/ But i am confused about it still. What i understood is that we must use an Interface to define a class .In the interface we will give the prototype of functions and later on we will define it in concrete class. Is that simple concept is Factory design pattern ?
View 13 RepliesI am developing an application in ASP.NET 3.5. i am exporting data to excel file using some interops dll's. earlier i have developed the applicaion in Windows 2003 Server. at that time i could able to export the data to excel file. but recently i have upgraded my pc to Vista version.it is working fine in my localhost. when i deploy the application in IIS iam getting this error. like "Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80070005.". can any one let me know the resolution for this error.
View 1 RepliesI wasn't getting this error before on localhost, but now it's occurring when I uploaded my ASP.NET C# web app to the server. I've been looking for an answer how to fix this, but cannot seem to get rid of it. I have a Microsoft.Office.Interop.Excel DLL which I am trying to use to export data from a dataset to excel. I was told by customer service that the domain that I have registered is hosted on a 32-bit server.
Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
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.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 80040154.
Source Error:
Line 499: object misValue = System.Reflection.Missing.Value;
Line 500:
Line 501: xlApp = new Excel.ApplicationClass();
Line 502: xlWorkBook = xlApp.Workbooks.Add(misValue);
Line 503: xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
I am having troubles understanding the purposes of using Factory pattern, I understand Factory pattern uses Factory class that has methods to return concrete objects. But why don't I simply use new opertor to create concrete objects? Some articles suggest Factory methods could return objects of different concreate classes, I can do the same thing by using switch statement.
Also are there classes in .Net framework already implementing Factory pattern? I think that will give me a better ideas why it is useful.
I am using below code to find find no of slides in .ppt,.pptx and .pot file .
Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open(path, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
count=pptPresentation.Slides.Count;
It is working file in my system , but online it is showing error :
Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
I have an aspx page which contains a web user control as below.
[code]...
In the Page_Load method of the above page I am setting the Visible = true/false (based on some condition) for the WebUserControl1. WebUserControl1 contains lots of control itself. But I don't want to initialize the controls inside WebUserControl1. Is there anyway we can avoid initializing the ChildControls of WebUserControl1?
So imagine a piece of Javascript as the first script on a page along the lines of
var MySuperObject = new (function () {
this.SuperObjectInit();
})();
Now imagine that everything that proceeds this script (or a large portion therein) requires the SuperObject to have met its load conditions and loaded correctly.
Assuming for whatever reason the loading of the object fails I need to abort loading the rest of the page and the scripts in particular.
I know the majority of you are going to scream why not have your function issue a callback onSuccess and onFailed but the problem is this is in a ASP.Net project with masterpages, nestedmasterpages, usercontrols and so forth (each of which have their own dependencies and scripts); rendering such an approach problematic.
The other option (I assume) is to use window.location = "myErrorPage.html"; but I dont like the idea of having to create another page for an error message or the fact that it causes a redirect.
What I am hoping to do is something along the lines of
StopLoadingPage();
document.write("Error has occurred");
1) As per my understanding, Session variables like HashTable and another variable in Session must be initialized. The best place as per my knowledge is Sesson_Start Event. But at some post its written that we must do that in Application_Start. I think it is not true, as that could lead to problems with different user sessions. Reference is this [URL] Let me know about the concept.
2) Storing variables like string, boolean and etc in Session is slower than storing objects in Session like HashTable, Arrays etc.. becuase they dont require boxing and unboxing. Is that true? Reference. [URL]
I am facing one problem that when i try to access a page in the website, i am getting the following error,
Retrieving the COM class factory for component with CLSID {58A02778-16FC-423D-91AC-4619BD71257F} failed due to the following error: 80040154.
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.Runtime.InteropServices.COMException: Retrieving the COM class factory for component with CLSID {58A02778-16FC-423D-91AC-4619BD71257F} failed due to the following error: 80040154.
Source Error:
[Code]....
Source File:
d:IEL_HELPDESKIEL-HelpDeskIELHelpDeskl_ticket_approval.aspx.cs
Line: 23 Stack Trace:
[Code]....
I went to that particular class file which is in the form of dll and in codebehind page of that class , builded the application, but it is not showing any compile time errors, but i put a break point it fails.
Retrieving the COM class factory for component with CLSID {86A3FE22-515C-45BF-B489-07DEEB03E2D6} failed due to the following error: 80040154.this is error message in my page in asp.net?
View 1 Replies