|
Thanks I seem to have gotten that one to work the way i want!
|
|
|
|
|
Good morning folks!
I'm trying to get a Session and redirect the user to another page, but it doesn' work.
If the user doesn't have permission then redirect to root: Default.aspx.
<br />
private UserStats userStats;<br />
<br />
protected void Session_Start(object sender, EventArgs e)<br />
{<br />
if ((UserStats)Session["UserStats"] != null)<br />
{<br />
userStats = (UserStats)Session["UserStats"];<br />
}<br />
}<br />
<br />
protected string PageBasePath<br />
{<br />
get<br />
{<br />
string basePathString = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Request.ApplicationPath);<br />
if (!basePathString.EndsWith("/")) basePathString = basePathString + "/";<br />
return basePathString;<br />
}<br />
}<br />
<br />
protected bool Compare(String x, String y)<br />
{<br />
Regex rg = new Regex(y);<br />
return rg.IsMatch(x);<br />
}<br />
<br />
protected void Application_PreRequestHandlerExecute(object sender, EventArgs e)<br />
{<br />
<br />
String ExtendsPermissions = "aspx|jpg|png"; <br />
String page = HttpContext.Current.Request.Path.ToString(); <br />
try<br />
{<br />
String expression = @"(/MYSITE/DIRECTORY/)(([a-zA-Z0-9_\/]+)*)\.(" + ExtendsPermissions + ")$";<br />
if (Compare(page, expression ) && userStats.Permission.Equals("DIRECTORY") )<br />
{ <br />
}<br />
else<br />
{<br />
<br />
HttpContext.Current.Response.Redirect(PageBasePath);
<br />
}<br />
}<br />
catch (Exception ex)<br />
{<br />
Response.Write(ex.Message);<br />
}<br />
}<br />
|
|
|
|
|
Better ask this in the asp.net forum.
|
|
|
|
|
hi all,
I wrote a service in c# and I prepared a setup to service but now
I want to unistall if service install before and then install last setup
how I do this??
thanks..
|
|
|
|
|
So you want to do an upgrade??
I will assume you have used a VS Setup project for doing this.
If you want your service to be updated and you use VS2008. Do the following:
Add a custom action for Install, Commit, Rollback and Uninstall and add "Primary output..." of your service project.
Add the Condition NOT PREVIOUSVERSIONSINSTALLED for Install and Commit.
In your Setup-project choose RemovePreviousVersion: True and change the UpgradeCode and Version .
IF you are using VS2005 you don't have to add the NOT PREVIOUSVERSIONSINSTALLED as a Condition. This was altered in VS2008.
I also assumed that you added a ProjectInstaller to your service project
|
|
|
|
|
"Add the Condition NOT PREVIOUSVERSIONSINSTALLED for Install and Commit.
In your Setup-project choose RemovePreviousVersion: True and change the UpgradeCode and Version"
how I add NOT PREVIOUSVERSIONSINSTALLED condition
and choose RemovePreviousVersion where is it??
|
|
|
|
|
I found them and I did them but it is not work
I unistall service "sc delete servisname" from command prompt ,is it necessary tu use this command?
|
|
|
|
|
No not really. Just to make sure I understand your question correctly, is this your scenario:
You have created a Windows Service (NT Service) and you have added a ProjectInstaller in that project.
You added a Setup project to your solution to install your Windows Service.
Now you want to make an upgrade of your Service, for instance upgrading from version 1.0 to 2.0.
Then you should do the following:
1. Create a Custom action to your Setup project for Install, Commit, Rollback and Uninstall, adding the Project Output.. of your Windows Service.
2. Change RemovePreviousVersion from false to true .
3. Change the Version of your Setup project (i.e. from 1.0 to 2.0).
4. Change the UpgradeCode of your Setup project (I believe VS asks you if you want to change this when you change the Version ).
5. If you are using VS 2008 (or 2010?), add the NOT PREVIOUSVERSIONSINSTALLED as a Condition . If you are using VS 2005, this is not necessary (Microsoft changed this behaviour between the 2005 and 2008 version of VS. This means that in 2008 the Service will not really be uninstalled in the Service Control Manager - only the binaries will we changed).
I know i repeated myself a bit from my previous answer, but this is actually the only steps you need to go through to make it work. If it doesn't work - please provide the code in your ProjectInstaller class , because maybe something is missing there. Also provide any error messages displayed.
You should not have to make any commands like "sc delete servisname" etc. All this should be taken care of by MSI.
|
|
|
|
|
thanks for your answers,you understand correctly my problem
my projectinstaller class only like this:
namespace SistemServis
{
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
}
I added aproject installer but I didn't add anything else.
Do I have to write different things???
|
|
|
|
|
Okay, then that's your problem. You have to add code to the ProjectInstaller class that actually does the installation of your service. In your case it would look something like this (from MSDN example):
namespace SistemServis
{
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
private ServiceInstaller serviceInstaller;
private ServiceProcessInstaller processInstaller;
public ProjectInstaller()
{
InitializeComponent();
processInstaller = new ServiceProcessInstaller();
serviceInstaller = new ServiceInstaller();
processInstaller.Account = ServiceAccount.LocalSystem;
serviceInstaller.StartType = ServiceStartMode.Manual;
serviceInstaller.ServiceName = "YourServiceName";
Installers.Add(serviceInstaller);
Installers.Add(processInstaller);
}
}
}
Good luck!
|
|
|
|
|
nothing changed
when I tried to install, service all times give this error:
error 1001:the apperred system is still there.
|
|
|
|
|
hmm.. that's odd. Could you make sure that your service is uninstalled when you run your "new" MSI (the one generated with the code I added), then make an install, change the version number (and upgrade code) and then perform an upgrade?
|
|
|
|
|
Hi Everyone
I am writing an Excel document in C#. I am writing it in 'Visual Studio 2008' and the project type is a '2007 Excel Workbook'. I was able to add all the controls and functionality I want to the Excel Workbook and it works. The problem is when I try to 'compile' (not sure if compile is the right word) the Excel document, it's dependent on a bunch of other files.
for example the resulting ExcelWorkbook2.xlsx file is dependent on a bunch of other files like:
ExcelWorkbook2.vsto
ExcelWorkbook2.dll
ExcelWorkbook2.dll.manifest
Is there a way to embed these files into the xlsx file so that the ExcelWorkbook2.xlsx will work on it's own?
I am writing this for some corporate people in my company and I think they'll have a hard time to remember to copy all these dependent files along with the Excel Workbook. So it would be nice to have everything in one file. I could probably write VBA Macros instead, but it would be nice to do it in C#.
Any help is appreciated
Regards
KOM UIT DAAAAA!!!
|
|
|
|
|
Ncb files are used for intellisense in C++ projects - at least that's the information I found in the web. Now I have a solution containing some 20 C# projects and one (1) C++ project, the main project being a C# project.
Before opening the solution (in Visual Studio 2005 Professional), I deleted the ncb file found in that project's directory. After closing the solution, an ncb file (with more than the size of all dlls and pdbs summed up) resides there.
Since the project is a C# project, I think that file is pretty useless, isn't it? How can I safely get rid of it?
By the way, I tried the tricks to be found by Google for C++ projects, they did not help here.
|
|
|
|
|
Did you try this:
Rename the file (VS root path)\VC\vcpackages\feacp.dll, then delete the .ncb file and now it should not be created again.
I am a HUMAN. I have that keyword (??? too much) in my name........
_AnsHUMAN_b>
|
|
|
|
|
Thanks for the hint. I tried it, then the freshly created ncb file was only a few kB in size. But intellisense in C++ projects did not work anymore...
|
|
|
|
|
That is because the ncb is the intellisense information. It was huge because it had generated the required information for all your C# projects just in case your C++ project was to reference them. The ncb is only used for intellisense and won't compile into your final solutions, so there really isn't much point in removing it from your solution as it will break your C++ intellisense.
|
|
|
|
|
Dear All!!!
I want to create webbrowser control at runtime. for this i created one class to handle runtime created webbrowser. meantime i will be calling this class in threads, might be 10 threads at a time.
I made one class where i am creating webbrowser control. and i have made properties and events to handle this browser.
if i call this without thread, its ok.
But i want to call this class in thread. i tried but the document completed event does not get fired in this class.
see the code...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WebBrowserExample
{
public class Class1
{
public WebBrowser Browser=new WebBrowser();
public delegate void DocumentCompletedDelegate(string DocumentText);
public event DocumentCompletedDelegate DocumentCompletedEvent;
public Class1()
{
Browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(Browser_DocumentCompleted);
}
public void NavigateUrl(string Url)
{
Browser.Navigate(Url);
}
public string DocumentText
{
get;
set;
}
void Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (Browser.ReadyState == WebBrowserReadyState.Complete&&Browser.Document!=null)
{
DocumentText = Browser.DocumentText;
if (DocumentCompletedEvent != null)
{
DocumentCompletedEvent(DocumentText);
}
}
}
}
}
I am calling this class through form ..
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;
namespace WebBrowserExample
{
public partial class Form1 : Form
{
Class1 class1;
Thread BrowserThread;
public Form1()
{
InitializeComponent();
class1 = new Class1();
class1.DocumentCompletedEvent += new Class1.DocumentCompletedDelegate(Class1_DocumentCompletedEvent);
}
void Class1_DocumentCompletedEvent(string DocumentText)
{
webBrowser1.DocumentText = class1.DocumentText;
}
private void button1_Click(object sender, EventArgs e)
{
BrowserThread = new Thread(StartBrowsing);
BrowserThread.SetApartmentState(ApartmentState.STA);
BrowserThread.Start();
}
void StartBrowsing()
{
class1.NavigateUrl("http://codeproject.com");
}
}
}
in this form there is webbrowser control so when class's browser gets completed the form's webbrowser document text should be updated.
Any idea will be appreciated .
Thanks!
|
|
|
|
|
The events will not work acrossed thread boundries. They will only get raised on the UI (startup) thread.
The browser will not work on anything other than the UI thread. You cannot create a new browser instance on a seperate thread and expect it to work.
|
|
|
|
|
The web browser must operate on the main thread. It's all very well getting information for it in background threads, but these must ultimately be marshalled back to the primary thread.
|
|
|
|
|
|
You're going to have to explain what you mean by that and where you're looking. You could be referring to about 5 different things that I know of.
And your subject line is stupid. You're posting in the C# forum, so it's pretty obvious you're dealing with C#.
|
|
|
|
|
Sorry but your question is not clear.
What exactly do you mean by a "cluster"?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
His reply:
I want to create webbrowser control at runtime. for this i created one class to handle runtime created webbrowser. meantime i will be calling this class in threads, might be 10 threads at a time.
OK. You don't really need an entire class to create a web browser instance, but whatever...
Your threads (10 is probably too many) would have to marshal whatever manipulations they want back to the UI thread to aply those changes to the browser control. This would require you to create appropriate methods to make the changes.
|
|
|
|
|
What would you like it to be?
|
|
|
|