|
Hello!
Has anybody used any kind of rebains with .NET and C#?
I've got hundreds of dll's and all have the same base address. I tried with rebase, but I think I'm not using it in the proper way. Any help?
Thanks,
Ivan.
Iván Fernández
|
|
|
|
|
See the NGen Overview. You can also "rebase" during compilation by using the /baseaddress compiler option or set it in the VS.NET project settings, or use the rebase tool.
The dox for rebase are here.
Ian Mariano - Bliki | Blog
"We are all wave equations in the information matrix of the universe" - me
|
|
|
|
|
Hello
I'm porting a Service administrator application written in C++ 6 to .Net C#.
This application install, uninstall, start, stop ... services written in .NET C#.
Everything is ok when installing a service.
My problem is on trying to start a service from my application or from the OS service agent, I get a error saying "Acces is denied".
When I use my old C++ 6 application I can install and start the same service without any problem.
Am I missing any security settings or have you any idea ?
Following a piece of the code I'm using:
[Flags]
public enum ServiceControlAccessRights : int
{
StandardRightsRequired = 0xf0000,
Connect = 0x00001,
CreateService = 0x00002,
EnumerateService = 0x00004,
Lock = 0x00008,
QueryLockStatus = 0x00010,
ModifyBootConfig = 0x00020,
AllAccess = 0xf003F
}
[Flags]
public enum ServiceControlType
{
OwnProcess = 0x010,
ShareProcess = 0x020,
KernelDriver = 0x001,
FileSystemDriver = 0x002,
InteractiveProcess = 0x100
}
[Flags]
public enum ServiceStartType
{
BootStart = 0x00,
SystemStart = 0x01,
AutoStart = 0x02,
DemandStart = 0x03,
Disabled = 0x04
}
[Flags]
public enum ServiceErrorType
{
ErrorIgnore = 0x00,
ErrorNormal = 0x01,
ErrorSevere = 0x02,
ErrorCritical = 0x03
}
[Flags]
public enum ServiceSpecificAccessType
{
QueryConfig = 0x0001,
ChangeConfig = 0x0002,
QueryStatus = 0x0004,
EnumerateDependents = 0x0008,
Start = 0x0010,
Stop = 0x0020,
PausContinue = 0x0040,
Interrogate = 0x0080,
UserDefinedControl = 0x0100,
AllAccess = 0xf01FF
}
#region DLLImport
[DllImport( "kernel32.dll", EntryPoint = "GetLastError" )]
public static extern int GetLastError();
[DllImport( "advapi32.dll", EntryPoint = "OpenSCManager" )]
public static extern int OpenSCManager( string machineName, string databaseName, ServiceControlAccessRights desiredAccess );
[DllImport( "advapi32.dll", EntryPoint = "CloseServiceHandle" )]
public static extern bool CloseServiceHandle( int hSCObject );
[DllImport( "advapi32.dll", EntryPoint = "CreateService" )]
public static extern int CreateService( int hSCManager, string serviceName, string displayName,
ServiceControlAccessRights desiredAccess, ServiceControlType serviceType, ServiceStartType startType, ServiceErrorType errorControl, string pathName,
string loadOrderGroup, string tagId, string dependencies, string serviceStartName, string password );
[DllImport( "advapi32.dll", EntryPoint = "OpenService" )]
public static extern int OpenService( int hSCManager, string serviceName, ServiceControlAccessRights desiredAccess );
[DllImport( "advapi32.dll", EntryPoint = "LockServiceDatabase" )]
public static extern int LockServiceDatabase( int handle );
[DllImport( "advapi32.dll", EntryPoint = "UnlockServiceDatabase" )]
public static extern bool UnlockServiceDatabase( int handle );
[DllImport( "advapi32.dll", EntryPoint = "ChangeServiceConfig" )]
public static extern bool ChangeServiceConfig( int hService,
ServiceControlType dwServiceType, int dwStartType, int dwErrorControl,
string lpBinaryPathName, string lpLoadOrderGroup, IntPtr lpdwTagId,
string lpDependencies, string lpServiceStartName, string lpPassword,
string lpDisplayName );
#endregion DLLImport
public bool InstallService( string svcPath, string svcName, string svcDispName )
{
try
{
int hScm = OpenSCManager( null, null, ServiceControlAccessRights.AllAccess );
if( hScm == 0 )
return false;
int hSvc = CreateService( hScm, svcName, svcDispName,
ServiceControlAccessRights.StandardRightsRequired |
ServiceControlAccessRights.CreateService |
ServiceControlAccessRights.ModifyBootConfig,
ServiceControlType.OwnProcess | ServiceControlType.InteractiveProcess,
ServiceStartType.DemandStart,
ServiceErrorType.ErrorNormal,
svcPath,
null, null, null, "LocalSystem", null );
if( hSvc == 0 )
{
int err = GetLastError();
CloseServiceHandle( hSvc );
CloseServiceHandle( hScm );
return false;
}
else
{
CloseServiceHandle( hSvc );
CloseServiceHandle( hScm );
return true;
}
}
catch( Exception e )
{
throw e;
}
}
Thanks
|
|
|
|
|
Hi,
Can we use .NET assemblies in ATL?
Regards
Tarun
Blue Pill or Red Pill........??
|
|
|
|
|
|
Hi,
How do I set background color for status bar?
Direct property not available.
Thankx
Priya
|
|
|
|
|
I don't believe you can. This is from docs (bolding is mine)...
The ProgressBar control displays a bar that fills in from left to right with the system highlight color as an operation progresses.
Jeff Martin
Triple20 Software
|
|
|
|
|
I know this question has been asked many times and althought I have browsed through several message boards, I can see the question but not the answers.
Because of that, I tried to figure out which method or methods the datagrid has to paint the column headers. Using reflection I found out that there are two methods: PaintColumnHeaders and PaintColumnHeaderText.
However, this methods are private and can't be overridden or hidden.
I can't understand why they made these methods private but anyway, does anyone know how to go around this?
also, there is a private method that returns the header rectangle. I was able using the MethodInfo.Invoke method to get this object but I can't do anything with it.
I am just learning to use the Reflection namespace I haven't figured out how to deal with this, any ideas?
|
|
|
|
|
Hi All,
I want to access a web service(methods) from java at runtime.
what are the ways for doing this?
Any Links to some articles on this would be appreciated
Thanks and Regards
Tushar mahajan.
|
|
|
|
|
Tushar mahajan wrote:
from java
Ummmm... You do realise that this is a .NET Framework forum, don't you? You might find your answer if you post your question to a Java related forum.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
Coming soon: The Second EuroCPian Event
|
|
|
|
|
|
Can someone direct me to step by step directions on how-to setup my computer (.Net 2002. W2K)so I can begin playing with web applications. I have IIS installed & running along with all the .NET options from the setup. I create a simple asp.net application. I add just a label. When I try to run it (f5) it complains about the debugger. If I start without debugging, I just get unformatted text. I must have the setup messed up.
|
|
|
|
|
Greetings
I am getting this exception from time to time when trying to connect to authorize.net. I can fix the problem by re-cycling the application pool (i.e. re-start IIS) but it only stays fixed for a couple days then it starts happening again. Here is the exact error.
Exception Details: System.EntryPointNotFoundException: Unable to find an entry point named EnumerateSecurityPackagesW in DLL security.dll.
I originally got this error on this serverr when I added this script to the website. I fixed it by adding the "ASPNET" user group to the file permissions for this page and set it to modify control. That got me going but only for a couple days and then it stops. It will process cards just fine when it is not throwing this error.
Very very odd. I cannot believe it is code related because of the sporadic nature and I use this EXACT SAME SCRIPT on another server and it works with zero problems.
By the way, I do not have a custom DLL named security.DLL that would be causing a conflict or any other custom DLL for that matter. I am completely stumped.
Any help out there? Rob
Rob Taylor
www.tconsult.com
|
|
|
|
|
When using P/Invokes, the Framework simply uses the Windows LoadLibraryEx function to load the library. You're therefore constrained by the DLL search order used by LoadLibrary .
I'm not sure exactly whether or when the Framework calls FreeLibrary . From my experience, I don't think it does, except possibly when unloading an AppDomain.
At a guess, I'd say your live server is running Windows 2000 and has a security.dll somewhere on the system - possibly in another virtual directory. When your application starts up, the ASPNET_WP worker process creates an AppDomain for your application. If somehow the current directory for the process is a directory which contains a security.dll , that will get loaded rather than the system's version, because the current directory appears before the system directory on Windows 2000. This problem will also occur on Windows XP before SP1. The default for XP SP1 and Windows Server 2003 is for the system directory to be searched before the current directory, but this can be altered by setting HKLM\System\CurrentControlSet\Control\Session Manager\SafeDllSearchMode to 0.
I think you could kludge this by P/Invoking the LoadLibrary function to explicitly load security.dll from the Windows directory. If you pass a path to LoadLibrary , that version will be loaded. Subsequently, any use of LoadLibrary without supplying the path information (as P/Invoke does) will use the version that's already loaded.
If you're going to do this - and I make no guarantees it will work - it probably needs to go in global.asax in an override of HttpApplication.Init .
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Good Heavens Mike we may have hit the Mother Load.
It is Server 2003 but you really jarred something in me when you said "Security.DLL" somewhere on the system - not necessarily in the web directory. As a result, I did a search of the entire web server and guess what I found? A file named security.dll in one of the other websites on there. It was from a long time ago and was for a web service I was screwing around with like a year ago. Think that could cause it to happen?
I do not know if that will do the trick but I now know the only thing(s) on here named security.DLL are system DLLs. BUT I still have three.
One named "System.Security.DLL" which is in "Microsoft.NET \Framework\v1.1.4322"
One Named "Security.DLL" in the "System32" folder
Another Named "Security.DLL" in "Microsoft.NET \Framework\v1.1.4322\Temporay ASP.NET Files\root\"
How does all that sound?
Rob
Rob Taylor
www.tconsult.com
|
|
|
|
|
Yep, that third one probably did it. I've thought of another way it could happen: if the other security.dll is a managed DLL.
The CLR still uses the LoadLibrary API to load managed DLLs, for compatibility with Managed C++ (in which it's possible to implement DLLs with so-called 'flat' exports) I think. This loads the DLL with an explicit path. If this gets loaded before the P/Invoke (embedded in the depths of System.DLL) happens, LoadLibrary will return a handle to this managed DLL rather than looking for the DLL in System32, even on Windows Server 2003. This could happen if another website in the same application pool which uses that DLL starts before your application does.
My solution of using LoadLibrary explicitly likely wouldn't help in that case.
If you can delete that extra security.dll , that's the easiest solution. I suspect it's being copied back there by a different web application, though. Check the bin directory under your application roots.
If you ever have to deal with a situation where another web application is using a security.dll (or any other name which conflicts with a system DLL), your best bet is probably to create a separate application pool for one of the conflicting applications. This will force it to get a different W3WP worker process (in IIS 6.0), so they won't conflict.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Hi Mike
What third one did the trick? Are you saying I should leave the security.dll alone that is located
is system32 and delete the other 2? One is in System32 and the other 2 are in "Framework" someplace.
Which should I delete?
I have looked in all the bins on the site and I got the security.DLLs out of there. While they
were not located directly in this application, I hope that was causing the problem.
This is great. I hope it solves the problem.
Rob
Rob Taylor
www.tconsult.com
|
|
|
|
|
http://www.tconsult.com/aspnet/server2003/entry_point_EnumerateSecurityPackagesW.aspx
Rob Taylor
www.tconsult.com
|
|
|
|
|
I have a small program that runs the MSDE installer, then attaches a database etc. Now MSDE installs MDAC, but the program imports System.Data.SqlClient, which requires MDAC, and works nearly on every target machine.
Am I correct in guessing that the runtime only loads the MDAC stuff when it is first required, so the first function call to install MSDE doesn't use any data access, and by the time the second runs, the data access dll's are already present.
My blog.
|
|
|
|
|
can anyone tell me how to open an existing microsoft word and microsoft powerpoint document in dot net?
seemeen
|
|
|
|
|
|
i dont think the article helped me much.
let me put this again:
need to know how to open word and power point sdocuments directly in the browser?
u see i have some pdf, word and powerpoint documents.they are placed in some location on my hard drive.
i have the paths of all thesein my SQL database.
now these paths appear in a data grid like hyper links its something like this:
doc1.ppt (power point file)
doc2.pdf (adobe file)
doc3.doc. ( word file)
so as soon as i click on a hyperlink, the selected document should open up in the browser directly.
the pdf files open directly the word and power point docs do not open.
Please note that i am developing an ASP.net (with VB.net) application
now how do i do this?
|
|
|
|
|
Hi there, Seemeen. I took from your original question that you wanted to write a .NET application that would open/manipulate word & powerpoint documents. It sounds like you want - from a user's point of view - to click a link and have the document open directly in the browser, rather than in a seperate instance of the application. Is this correct?
If that is the case, you are dealing with a client-side issue then, not a server-side issue. It's up to the client machine to determine how a document will open. I believe IE by default will open Microsoft Office documents inline rather than in a seperate instance window - so there may be a setting configured on your client machine that is forcing the documents to open seperately. Here are some links to relevant KB articles:
http://support.microsoft.com/?kbid=162059[^]
http://support.microsoft.com/default.aspx?scid=kb;en-us;254918[^]
http://support.microsoft.com/default.aspx?scid=kb;en-us;193823[^]
You can check the settings it describes to see if you have any of them set on your machine.
|
|
|
|
|
How can you install the DOT net framework completly silently? I use the /Q in the command line of dotnetfx.exe, but it prompts me for the lisence agreement. Is there a way to install it completly silently? I need to do an administrative install on many computers, and it is not possible to click ok for each one.
thanks
|
|
|
|
|
I have an application, that is built using 1.0.1515.12345 of a component in the GAC. I have auxillary programs(dlls) that also depend on the exact same version. I was hoping there was some way to examine the compiled dll (that doesn't load), to find out which version of the GAC based component it is depending on. All I seem to be able to glean at this point is that it won't load.
I'm hoping to be a little more helpful to the developers of these Dll's.
If I can't then i guess that's life.
I found this article on here on Codeproject.Undocumented Fusion[^]
|
|
|
|
|