|
Navigation properties cannot span multiple DbContext types.
If you want an entity type in one context to map to the same table as a type in a different context, then you will need to use the OnModelCreating method to explicitly map it to the correct table. You may also need to exclude it from migrations.
There's a good example in this blog post for EF Core 5 RC1:
Announcing Entity Framework Core (EFCore) 5.0 RC1 - .NET Blog[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Does a .NET 8 application need to be "published" before it can run properly?
Or is building it good enough?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Building it is good enough. Publishing just packages the thing up for distribution.
You don't even need to "publish" the app is you know all the files in the app that must be distributed. You can just pick out the files and make an installer with them if you know what files you need.
|
|
|
|
|
Thanks! I'm making my first foray into .NET 8 coming from the .NET Framework.
Never thought I could learn this, but it's coming along.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I only use Publish if it's an Azure web (Blazor) app or Azure Function app. For console apps I just copy everything in and under <project>\bin\Release\net8.0 to the new destination.
There are no solutions, only trade-offs. - Thomas Sowell
A day can really slip by when you're deliberately avoiding what you're supposed to do. - Calvin (Bill Watterson, Calvin & Hobbes)
|
|
|
|
|
A tool for diagnosing which DLL is unable to be loaded by a subject DLL? I've used DUMPBIN to list the static dependencies of the DLL and they are very few and all of them are in the same directory as the subject DLL.
This isn't my DLL so I have no idea what it's doing in its DllLoad routine. But the Windows loader is just a black box. It gives no insight into what's going on during the DLL load.
This is a .NET 8 project that is calling functions in the subject DLL through pinvoke, so maybe the .NET loader knows something.
Anyone know how to debug this?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
First thought is to start removing dll's and see if the messages change / appear. Look at build dates.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Thanks Gerry, I finally figured it out!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png)
To diagnose which DLL is unable to be loaded by a subject DLL, especially in a .NET context, you can utilize several tools and methods:
Dependency Walker
- **Tool**: Dependency Walker (depends.exe)
- **Usage**: This tool analyzes the dependencies of a DLL and can help you see which DLLs are missing or failing to load. It provides a detailed tree view of all dependencies, showing the status of each one.
- **Steps**:
1. Download Dependency Walker from [dependencywalker.com](http:
2. Open your subject DLL with Dependency Walker.
3. Check for any missing or red-colored entries in the tree.
Process Monitor (ProcMon)
- **Tool**: Process Monitor (part of Sysinternals Suite)
- **Usage**: ProcMon allows you to capture real-time file system, registry, and process/thread activity. This can help you see which DLLs are being accessed and which ones are failing to load.
- **Steps**:
1. Download and run Process Monitor from [Microsoft Sysinternals](https:
2. Set a filter for your application (use the process name).
3. Look for "NAME NOT FOUND" or "DLL NOT FOUND" events, which indicate that a specific DLL could not be loaded.
### 3. **Fusion Log Viewer**
- **Tool**: Fusion Log Viewer (Fuslogvw.exe)
- **Usage**: This tool logs assembly binding failures, which can be particularly useful for .NET applications to determine why a specific assembly (DLL) failed to load.
- **Steps**:
1. Open the Developer Command Prompt for Visual Studio.
2. Run `fuslogvw.exe`.
3. Enable logging and reproduce the issue.
4. Check the logs for any binding errors or issues related to your subject DLL.
### 4. **.NET Assembly Binding Logging**
If the subject DLL is a .NET assembly, you can enable assembly binding logging in the registry:
- **Steps**:
1. Open `regedit`.
2. Navigate to `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion`.
3. Create a new DWORD value named `ForceLog` and set it to `1`.
4. Create a new DWORD value named `LogPath` and set it to a directory where you want the logs saved.
5. Reproduce the issue, and check the logs in the specified directory.
### 5. **Debugging with Visual Studio**
- If you have the source code for the .NET application, you can attach the debugger to your application and set breakpoints around the P/Invoke calls.
- Check for exceptions thrown during the load process. The exception messages can often provide insight into what went wrong.
*Using LoadLibraryEx
If you're able to modify the .NET code, consider wrapping your P/Invoke calls with `LoadLibraryEx`, which allows you to specify additional flags to get more detailed error information.
Using these tools in combination should help you identify which DLL is failing to load and provide insights into the cause of the failure. If you encounter specific error messages or issues along the way, feel free to share, and I can help troubleshoot further!
Navicosoft.com
navicosoft.com.au
navicosoft.co.uk
|
|
|
|
|
Hello,
I want to send a message/test to a other windows.
It should save me many time in putting me many time
strings/textes in MS Project, Outlook, ... ...
Therefore i want to use the Windwos API in VB.net.
I tried it in this way, but it doesn't work.
I get the windows handle, but the text isn't set at notepad or in a other window.
Private Sub tmr_Worktimer_Tick(sender As Object, e As EventArgs) Handles tmr_Worktimer.Tick
If IsKeyPressed(Keys.VK_SHIFT) Then
Dim aPoint As New POINTAPI
GetCursorPos(aPoint)
Dim hWnd As IntPtr = WindowFromPoint(aPoint.x, aPoint.y)
SetForegroundWindow(hWnd)
SetWindowTextUnicode(hWnd, WM_SETTEXT, IntPtr.Zero, "Test")
End If
End Sub
My API Calls are:
Public Structure Keys
Const VK_BACK As Short = &H8
Const VK_TAB As Short = &H9
Const VK_RETURN As Short = &HD
Const VK_SHIFT As Short = &H10
Const VK_CONTROL As Short = &H11
Const VK_MENU As Short = &H12
Const VK_CAPITAL As Short = &H14
Const VK_ESCAPE As Short = &H1B
Const VK_SPACE As Short = &H20
Const VK_PRIOR As Short = &H21
Const VK_NEXT As Short = &H22
End Structure
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Public Function GetAsyncKeyState(ByVal vKey As Int32) As Short
End Function
Public Function IsKeyPressed(ByVal KeyToCheck As Short) As Boolean
Dim res As Short
res = GetAsyncKeyState(KeyToCheck)
If res < 0 Then
IsKeyPressed = True
Else
IsKeyPressed = False
End If
End Function
<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)>
Public Structure POINTAPI
Dim x As Integer
Dim y As Integer
End Structure
<DllImport("user32.dll", ExactSpelling:=True, SetLastError:=True)>
Public Function GetCursorPos(ByRef lpPoint As POINTAPI) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
<DllImport("user32.dll")>
Public Function WindowFromPoint(xPoint As Integer, yPoint As Integer) As IntPtr
End Function
<DllImport("user32.dll")>
Public Function SetForegroundWindow(hWnd As IntPtr) As Boolean
End Function
Friend Const WM_SETTEXT As Integer = 12
<DllImport("user32.dll", EntryPoint:="SendMessageW", CharSet:=CharSet.Unicode)>
Public Function SetWindowTextUnicode(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr
End Function
Any ideas? Is there a other way to send the string/text?
|
|
|
|
|
You need to use the debugger to see which of those API calls is failing. As it stands your code has no idea whether anything works.
|
|
|
|
|
The problem is, it didn't fail.
So i ask, if i use the right api call.
Or is there a better way to copy a string to a other textbox on a foreight form/app, then the "SendMessageW" API call?
|
|
|
|
|
Seek51 wrote: The problem is, it didn't fail. That is not what you said in your original question. So you need to be much more specific about the actual problem you have.
|
|
|
|
|
Seek51 wrote: The problem is, it didn't fail.
How exactly do you know that? Did you run it in the debugger?
Otherwise I don't see an exception handler.
And you are not looking at return values. For example SetForegroundWindow() which returns a boolean. And that value tells you whether it worked or not.
|
|
|
|
|
Myself that certainly does not look to me like that code would work.
Best I can see you are perhaps sending text to the desktop?
In other words the Windows UI is not the same as the processes that run.
When I googled for this solutions the Microsoft code I found suggests exactly what I would expect the process to be.
How to: start an Application and send it Keystrokes - Visual Basic | Microsoft Learn[^]
I suppose it might be possible to find an app using the UI, but sending key presses to it will still require the proc id.
|
|
|
|
|
|
As most of the comments suggest above, use a debugger in your code. You have a lot of else statements that will override a normal error, which is why you get no errors but also no warnings/comments in your log file...
|
|
|
|
|
Hello everyone,
I have a case with vlc on my ubuntu container. Indeed, my c# method :
<pre lang="C#">if (File.Exists(video.Path))
{
using (var libVLC = new LibVLC(enableDebugLogs: true))
{
this.logger.LogInformation($"ImageDetectionWorker.StartFramesPredictionVLC : VLC lib initialized")
if (Directory.Exists("/shared-volume/vlc" == false))
{
Directory.CreateDirectory("/shared-volume/vlc")
}
libVLC.SetLogFile($"/shared-volume/vlc/vlc.log";)
var absoluteVideoPath = new FileInfo(video.Path.FullName)
using (var media = new Media(libVLC, absoluteVideoPath, options: "--no-audio --no-xlib --no-sout-audio"))
{
this.logger.LogInformation($"ImageDetectionWorker.StartFramesPredictionVLC : VLC media initialized")
using (var mediaPlayer = new MediaPlayer(media))
{
this.logger.LogInformation($"ImageDetectionWorker.StartFramesPredictionVLC : VLC media player initialized")
mediaPlayer.ToggleMute()
Throw this logs in my container:
info: EigenVectors.PredictionWrite.Api.Workers.ImageDetectionWorker[0] ImageDetectionWorker.StartFramesPredictionVLC : Start to initialize VLC core info: EigenVectors.PredictionWrite.Api.Workers.ImageDetectionWorker[0] ImageDetectionWorker.StartFramesPredictionVLC : VLC core initialized [00007f897c0027e0] main libvlc debug: VLC media player - 3.0.20 Vetinari [00007f897c0027e0] main libvlc debug: Copyright © 1996-2023 the VideoLAN team [00007f897c0027e0] main libvlc debug: revision 3.0.20-0-g6f0d0ab126b [00007f897c0027e0] main libvlc debug: configured with ./configure '--build=x86_64-linux-gnu' '--prefix=/usr' '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' '--sysconfdir=/etc' '--localstatedir=/var' '--disable-option-checking' '--disable-silent-rules' '--libdir=${prefix}/lib/x86_64-linux-gnu' '--runstatedir=/run' '--disable-maintainer-mode' '--disable-dependency-tracking' '--disable-debug' '--config-cache' '--disable-update-check' '--enable-fast-install' '--docdir=/usr/share/doc/vlc' '--with-binary-version=3.0.20-0+deb11u1' '--enable-a52' '--enable-aa' '--enable-aribsub' '--enable-avahi' '--enable-bluray' '--enable-caca' '--enable-chromaprint' '--enable-chromecast' '--enable-dav1d' '--enable-dbus' '--enable-dca' '--enable-dvbpsi' '--enable-dvdnav' '--enable-faad' '--enable-flac' '--enable-fluidsynth' '--enable-freetype' '--enable-fribidi' '--enable-gles2' '--enable-gnutls' '--enable-harfbuzz' '--enable-jack' '--enable-kate' '--enable-libass' '--enable-libmpeg2' '--enable-libxml2' '--enable-lirc' '--enable-mad' '--enable-matroska' '--enable-mod' '--enable-mpc' '--enable-mpg123' '--enable-mtp' '--enable-ncurses' '--enable-notify' '--enable-ogg' '--enable-opus' '--enable-pulse' '--enable-qt' '--enable-realrtsp' '--enable-samplerate' '--enable-sdl-image' '--enable-sftp' '--enable-shine' '--enable-shout' '--enable-skins2' '--enable-soxr' '--enable-spatialaudio' '--enable-speex' '--enable-svg' '--enable-svgdec' '--enable-taglib' '--enable-theora' '--enable-twolame' '--enable-upnp' '--enable-vdpau' '--enable-vnc' '--enable-vorbis' '--enable-x264' '--enable-x265' '--enable-zvbi' '--with-kde-solid=/usr/share/solid/actions/' '--disable-aom' '--disable-crystalhd' '--disable-d3d11va' '--disable-decklink' '--disable-directx' '--disable-dsm' '--disable-dxva2' '--disable-fdkaac' '--disable-fluidlite' '--disable-freerdp' '--disable-goom' '--disable-gst-decode' '--disable-libtar' '--disable-live555' '--disable-macosx' '--disable-macosx-avfoundation' '--disable-macosx-qtkit' '--disable-mfx' '--disable-microdns' '--disable-opencv' '--disable-projectm' '--disable-schroedinger' '--disable-sparkle' '--disable-srt' '--disable-telx' '--disable-vpx' '--disable-vsxu' '--disable-wasapi' '--enable-alsa' '--enable-dc1394' '--enable-dv1394' '--enable-libplacebo' '--enable-linsys' '--enable-nfs' '--enable-udev' '--enable-v4l2' '--enable-wayland' '--enable-libva' '--enable-vcd' '--enable-smbclient' '--disable-oss' '--enable-mmx' '--enable-sse' '--disable-neon' '--disable-altivec' '--disable-omxil' 'build_alias=x86_64-linux-gnu' 'CFLAGS=-g -O2 -ffile-prefix-map=/build/reproducible-path/vlc-3.0.20=. -fstack-protector-strong -Wformat -Werror=format-security ' 'LDFLAGS=-Wl,-z,relro -Wl,-z,now' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'CXXFLAGS=-g -O2 -ffile-prefix-map=/build/reproducible-path/vlc-3.0.20=. -fstack-protector-strong -Wformat -Werror=format-security ' 'OBJCFLAGS=-g -O2 -ffile-prefix-map=/build/reproducible-path/vlc-3.0.20=. -fstack-protector-strong -Wformat -Werror=format-security' [00007f897c0027e0] main libvlc debug: searching plug-in modules [00007f897c0027e0] main libvlc debug: loading plugins cache file /usr/lib/x86_64-linux-gnu/vlc/plugins/plugins.dat [00007f897c0027e0] main libvlc debug: recursively browsing `/usr/lib/x86_64-linux-gnu/vlc/plugins' [00007f897c0027e0] main libvlc debug: plug-ins loaded: 519 modules [00007f897c001ad0] main logger debug: looking for logger module matching "any": 4 candidates [00007f897c001ad0] main logger debug: using logger module "console" [00007f897c0027e0] main libvlc debug: translation test: code is "C" [00007f8984270880] main keystore debug: looking for keystore module matching "memory": 4 candidates [00007f8984270880] main keystore debug: using keystore module "memory" [00007f897c0027e0] main libvlc debug: CPU has capabilities MMX MMXEXT SSE SSE2 SSE3 SSSE3 SSE4.1 SSE4.2 AVX AVX2 FPU info: EigenVectors.PredictionWrite.Api.Workers.ImageDetectionWorker[0] ImageDetectionWorker.StartFramesPredictionVLC : VLC lib initialized info: EigenVectors.PredictionWrite.Api.Workers.ImageDetectionWorker[0] ImageDetectionWorker.StartFramesPredictionVLC : VLC media initialized info: EigenVectors.PredictionWrite.Api.Workers.ImageDetectionWorker[0] ImageDetectionWorker.StartFramesPredictionVLC : VLC media player initialized info: EigenVectors.PredictionWrite.Api.Workers.ImageDetectionWorker[0] ImageDetectionWorker.StartFramesPredictionVLC : True ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
My Dockerfile :
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build-env
WORKDIR /app
EXPOSE 80
COPY . .
RUN dotnet restore MyProject.csproj
RUN dotnet publish MyProject.csproj -c Release -o out --no-restore
FROM mcr.microsoft.com/dotnet/aspnet:6.0
WORKDIR /app
COPY --from=build-env /app/out .
RUN apt-get update && apt-get install -y vlc && apt-get install libvlc-dev
ENV LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/:$LD_LIBRARY_PATH
ENTRYPOINT ["dotnet", "MyProject.dll"]
I've tried a lot of package to install on the container without any success
|
|
|
|
|
Quote: ALSA lib confmisc.c:767:(parse_card) cannot find card '0' ALSA lib conf.c:4745:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory ALSA lib confmisc.c:392:(snd_func_concat) error
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Lets start off with a little honesty - I am unsure of exactly what I am asking, but I am sure that someone can help.
So I currently have Visual Studio 17.8 installed. I predominantly work in VB.NET. I have some older code downloaded from Github, that works just fine (as binary) when it was put together say 10 or more years ago. The crux of the problem is that you (and by you, I mean me) cannot in some cases simply drop it into VS 17.8 without several errors.
Therefore, the naïve question is - can anyone point to a good source of information that would guide me on how to "upgrade" older code to eliminate errors in compiling with the current versions of VS and .NET?
THanks.
Pound to fit, paint to match
|
|
|
|
|
I'm interested ... what is older VB.Net Code and what is newer Code ?
I would say that your question isn't to answer without more and specific Info ...
|
|
|
|
|
You make a copy of the project, and try and compile it; then you can catastrophize.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
lewist57 wrote: cannot in some cases simply drop it into VS 17.8 without several errors
Without the code and the specific errors, its impossible to tell you what the problem is.
At a guess, are you trying to open a project that targets a version of .NET / .NET Framework for which you haven't installed the relevant VS targeting pack?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
It all depends on what the errors are. So you need to post a properly detailed question.
|
|
|
|
|
Ok, my previous post was a great example of how not to describe what I am looking for, mea culpa.
To give a more concrete example: Fast Colored Textbox is available here on CodeProject, as well as Github. It was posted in 2014, and has a target framework of .NET Framework 3.5. With VS 2022 17.8.2 (as of yesterday), the default target framework is .NET 8.0.
To clarify: evidently, even though I am sure that Microsoft works very hard to keep backward compatibility, the process of upgrading the program to .NET 8.0 is not trouble free. When you open the original files and start building, VS 2022 starts with a "One-way upgrade" conversion, and it says it successfully migrated. When you build the project, you get a dozen errors about "invalid RESX file".
Now I have not dug into the errors per se, but the naïve question is what is the root cause of these errors? Is it:
a) Just a matter of ensuring all supporting files are in a location that the compiler can work with, or
b) You can't count on the "one way upgrade" to do everything for you, or
c) There is code from 2008 - 2014 .NET 3.5 that is not compatible with .NET 8.0, or
d) all of the above, or something else
Of the three, it is item C that I am mainly concerned with.
Hope this makes more sense than the original post. Thanks to all for input received to date.
BTW: I mentioned that I work mainly in VB.NET as a nice way of saying I do not do programming for a living.
Pound to fit, paint to match
modified 1-Dec-23 9:47am.
|
|
|
|
|