Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Eventviewer not able to find PocoFoundation DLL #3304

Closed
KevDi opened this issue Jun 9, 2021 · 12 comments
Closed

Windows Eventviewer not able to find PocoFoundation DLL #3304

KevDi opened this issue Jun 9, 2021 · 12 comments

Comments

@KevDi
Copy link
Contributor

KevDi commented Jun 9, 2021

I want to log from my Application to the Windows Event Log.
When i run the Application as an Administrator it creates the Registry Keys under the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog Path. Without Admin Rights the key is not created.
I have placed the PocoFoundation64.dll inside the System32 Folder but in the Eventlog it still gives me the message:

the description for event id from source cannot be found

I'm using Poco in Version 1.10.1

@KevDi
Copy link
Contributor Author

KevDi commented Jun 30, 2021

@obiltschnig I further investigate on that problem. If i make a visual studio build directly from the provided Visual Studio Solution file inside the Poco Foundation Folder and use that created lib and dll File it works.
But if i made a CMake Build or use the Conan Package Manager there seems to be two Problems:

  1. CMake/Conan gives me a PocoFoundationd.dll instead of the PocoFoundation64d.dll which was created by the Visual Studio Solution File.
  2. The setUpRegistry() Function in the EventlogChannel.cpp could not find the dll because of the Naming missmatch. As shown here:
if (disp == REG_CREATED_NEW_KEY)
	{
		std::wstring path;
		#if defined(POCO_DLL)
			#if defined(_DEBUG)
				#if defined(_WIN64)
					path = findLibrary(L"PocoFoundation64d.dll");
				#else
					path = findLibrary(L"PocoFoundationd.dll");
				#endif
			#else
				#if defined(_WIN64)
					path = findLibrary(L"PocoFoundation64.dll");
				#else
					path = findLibrary(L"PocoFoundation.dll");
				#endif
			#endif
		#endif

Also manually adding the Registry Keys and pointing them to the PocoFoundationd.dll does not work.
This is also the same for the Release Build.

@obiltschnig obiltschnig self-assigned this Jun 30, 2021
@obiltschnig obiltschnig added this to the Release 1.11.1 milestone Jun 30, 2021
@obiltschnig
Copy link
Member

Thanks for looking into it. The solution is then probably to pass an additional preprocessor macro when building POCO, indicating that CMake is being used, so that the expected DLL name can be set accordingly.

@KevDi
Copy link
Contributor Author

KevDi commented Jun 30, 2021

where should it be placed? so maybe i can fix this and send you a merge request to fix this

@obiltschnig
Copy link
Member

Probably add a definition like:

target_compile_definitions(Foundation PUBLIC POCO_CMAKE)

to Foundation/CMakeLists.txt and then change EventlogChannel.cpp accordingly.

@KevDi
Copy link
Contributor Author

KevDi commented Jun 30, 2021 via email

@KevDi
Copy link
Contributor Author

KevDi commented Jul 1, 2021

@obiltschnig is there already a branch for the 1.11.1? Or should i take the master or the devel branch as a base?

@aleks-f
Copy link
Member

aleks-f commented Jul 1, 2021

@KevDi take master as a base and hold on with pull request until we sort the branches out - master and devel need to be re-aligned, and there will be contrib branch (where your pull should go)
unless there are some critical bugs discovered, the next release will be 1.12.0

@aleks-f
Copy link
Member

aleks-f commented May 18, 2022

@KevDi it's been a while, sorry about that; we're getting ready to release 1.12, so you can send it there, or if you're late for release, you can send to 1.12.1

@mapogu
Copy link

mapogu commented Sep 19, 2022

I've tested this on 1.12.2 and I still think for both win32 and x64 that the message definitions are not found when when looking at log points in EventViewer application. I have confirmed by opening the dll in Visual Studio that they are not part of PocoFoundation dll.

In my case I'm building Poco through cmake using generator for Visual Studio 17 2022. In addition to this I can see that cmake does generate the Message00001.bin file as well as the corresponding rc file. (Basically running mc compiler on pocomsg.mc) The output can be found in the CMAKE_CURRENT_BIN_DIR for PocoFoundation. However the rc file for PocoFoundation doesn't include the generated PocoMsg.rc file. Hence the resulting dll doesn't contain the necessary message definitions and therefor it will not work with having PocoFoundation registered in the registry.

I think it would be good if either the PocoFoundation rc files includes PocoMsg.rc for Win32 or x64 windows target, or that there is a cmake build options which besides generating the pocomsg.rc also performs the resource compile and link into PocoMsg.dll. ( ofc these option would only be valid for windows platform).

# Compile rc file to res file
rc pocomsg.rc

# Link into no entry dll
link -dll -noentry -MACHINE:x64 pocomsg.res

If the above is not an option, then maybe at least a note in the build instructions would be nice, in case somebody else stumbles upon same issue.

@github-actions
Copy link

github-actions bot commented Oct 5, 2023

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the stale label Oct 5, 2023
@Smurf-IV
Copy link

Smurf-IV commented Oct 5, 2023

I am interested in a fix for this and an example on it's usage please

@aleks-f aleks-f removed this from 1.13 Mar 20, 2024
@aleks-f aleks-f added this to 1.14 Mar 20, 2024
@matejk matejk removed this from 1.14 Nov 25, 2024
@matejk matejk modified the milestones: Release 1.14.0, Release 1.15.0 Nov 25, 2024
@KevDi
Copy link
Contributor Author

KevDi commented Nov 30, 2024

@aleks-f @matejk could this problem maybe solved by adding the generated rc File to the SRC List in CMake? From what i saw so far it looks like it is compiled but the responding rc file is never added to the SRC List when building the DLL?
I try to test it somewhere next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

6 participants