Print Page | Close Window

VS2008 UserControl

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce Classic
Forum Discription: For .NET 2.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=829
Printed Date: 02-Feb-2026 at 11:52pm


Topic: VS2008 UserControl
Posted By: pucsoftware
Subject: VS2008 UserControl
Date Posted: 06-Jun-2008 at 7:21am
I have created three projects. One is the DevExpress objects for my data, the second is a user control that uses the first project where I have created a Windows user control to access the data. The third project is a test form that references the first two projects. When I place the user control from the second project on the form I get an error message that a valid configuration file can not be found. This was working but as I continued to build the user control I started getting this error and the user control can't be displayed on my Windows form. I'm including a picture of the error I am getting. Can you tell me what is wrong?
 
Darren



Replies:
Posted By: pucsoftware
Date Posted: 06-Jun-2008 at 8:00am
After messing with this some, I figure that this issue has something to do with deployment of the necessary files. Even though I have all these projects in one solution, and the second project with the user control works correctly, the third project with the windows form is missing something. I made sure that the windows form project had references to all the same devexpress and devforce assemblies that the project with the user control has. This helped but didn't fix the problem. I'm getting a similar message but with different errors. Here is another picture of what I'm getting.
 
Darren


Posted By: davidklitzke
Date Posted: 06-Jun-2008 at 8:22am
Darren,
 
I have helped many customers with this problem.  For example, this is a typical response:

 
We have resolved your problem.

You will need to change the load handler for your User Control.

Change this code:

 

#Region "UserControl Events"

    Private Sub UserControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

            mPersMgr = PersistenceManager.DefaultManager

    End Sub

 

To this code:

 

#Region "UserControl Events"

    Private Sub UserControl_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If Not Me.DesignMode Then

            mPersMgr = PersistenceManager.DefaultManager

        End If

    End Sub

The reason for this code change is that the Visual Studio Designer will blow up if it executes any PersistenceManager code.  Apparently, the Load event occurs in the Designer.  By checking whether your code is executing in the Designer (by testing whether DesignMode is true), you stop the assignment of your private PersistenceManager.

 



Posted By: pucsoftware
Date Posted: 11-Jun-2008 at 11:24am
Thanks for your response. This worked.
 
Darren



Print Page | Close Window