I have two problems with apparently different symptoms, which I think may be the same problem. Both problems occur on one machine, but not on others.
In one case a .NET library is loaded in an old C++/MFC application. This library opens a WPF window, which generates the following error:
Set property 'System.Windows.ResourceDictionary.Source' threw an exception.
Cannot locate resource 'resourcedictionaries/images/bitmaps_32_32.xaml'.
The second error occurs on starting a WPF application. The program crashes on loading and writes the following error into the windows event log:
Anwendung: Cs3SystemManager.exe
Frameworkversion: v4.0.30319
Beschreibung: Der Prozess wurde aufgrund einer unbehandelten Ausnahme beendet.
Ausnahmeinformationen: System.IO.IOException
bei MS.Internal.AppModel.ResourcePart.GetStreamCore(System.IO.FileMode, System.IO.FileAccess)
bei System.IO.Packaging.PackagePart.GetStream(System.IO.FileMode, System.IO.FileAccess)
bei System.IO.Packaging.PackWebResponse+CachedResponse.GetResponseStream()
bei System.IO.Packaging.PackWebResponse.GetResponseStream()
bei System.IO.Packaging.PackWebResponse.get_ContentType()
bei MS.Internal.WpfWebRequestHelper.GetContentType(System.Net.WebResponse)
bei MS.Internal.WpfWebRequestHelper.GetResponseStream(System.Net.WebRequest, MS.Internal.ContentType ByRef)
bei System.Windows.ResourceDictionary.set_Source(System.Uri)
bei System.Windows.Baml2006.WpfSharedBamlSchemaContext+<>c.<Create_BamlProperty_ResourceDictionary_Source>b__342_0(System.Object, System.Object)
bei System.Windows.Baml2006.WpfKnownMemberInvoker.SetValue(System.Object, System.Object)
bei MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(System.Xaml.XamlMember, System.Object, System.Object)
bei MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(System.Object, System.Xaml.XamlMember, System.Object)
Ausnahmeinformationen: System.Windows.Markup.XamlParseException
bei System.Windows.Markup.WpfXamlLoader.Load(System.Xaml.XamlReader, System.Xaml.IXamlObjectWriterFactory, Boolean, System.Object, System.Xaml.XamlObjectWriterSettings, System.Uri)
bei System.Windows.Markup.WpfXamlLoader.LoadBaml(System.Xaml.XamlReader, Boolean, System.Object, System.Xaml.Permissions.XamlAccessLevel, System.Uri)
bei System.Windows.Markup.XamlReader.LoadBaml(System.IO.Stream, System.Windows.Markup.ParserContext, System.Object, Boolean)
bei System.Windows.Application.LoadComponent(System.Object, System.Uri)
bei Cs3SystemManager.App.InitializeComponent()
bei Cs3SystemManager.App.Main()
This application refers to the same resource dictionary which is referenced in the first error message. My strong suspicion is that it is the same basic error.
The resource dictionary is referenced with the syntax:
<ResourceDictionary Source="/McWpfResources;component/ResourceDictionaries/Images/Bitmaps_32_32.xaml" />
I have also tried the following syntax, but it did not make any difference.
<ResourceDictionary Source="pack://application:,,,/McWpfResources;component/ResourceDictionaries/Images/Bitmaps_32_32.xaml" />
Our installation stores executable files (.exe) into a directory called bin, and the DLL's into a subdirectory called bin\interop (some of them are interop wrappers for COM components).
For each .exe file, there is a matching .exe.Config file which speficies the privatePath, for example:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="interop"/>
</assemblyBinding>
</runtime>
</configuration>
If I copy the exe files down into the interop directory, neither of the problems occurs.
Clearly, the privatePath parameter is not working in this specific case (at least not working as I expect), but it does seem to work on other machines and in other applications.
Obviously, I can fix the error by putting everything in one directory, but apart from that, how can I fix the error?
Forget it. This was my error.
From a previous installation, the bin directory contained an old version of a DLL which is now installed into the interop subdirectory. This old DLL was being loaded in preference to the DLL in the subdirectory.
I might delete this question (or I might leave it as a cautionary tale).
Related
I've just migrated my .NET 4.8 Windows Forms application to .NET 5. The process was incredibly easy. The only problem I'm having is with Deploy. I've been using Click Once deploy with my application for years but after changing it to .NET5 and recreating the deploy, I'm getting this error. I also get the same error if I use the simpler Folder (non Click Once) deploy option. I'm deploying to a server share folder (\\HYDRA\Data\SL\IceTool) which is writable (the deploy task does actually copy the application executable into the share folder - but nothing else).
The error appears in a dialogue box containing the following text:
Publish has encountered an error.
Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
A diagnostic log has been written to the following location:
"C:\Users\Chris\AppData\Local\Temp\tmpF29C.tmp"
The tmpF29C.tmp file contains:
17/12/2020 01:05:34
System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
===================
Checking the output build log shows that the solitary Ice.exe file is "being used by another process":
2>Native image obj\Release\net5.0-windows\win-x64\R2R\Ice.dll generated successfully.
2>Skipping target "_CreateR2RSymbols" because it has no outputs.
2>Though the target has declared its outputs, the output specification only references empty properties and/or empty item lists.
2>Task "NETSdkError" skipped, due to false condition; ('#(_ReadyToRunCompilationFailures)' != '') was evaluated as ('' != '').
2>Task "NETSdkInformation" skipped, due to false condition; ('$(_ReadyToRunCompilerHasWarnings)' != '') was evaluated as ('' != '').
2>Target "GeneratePublishDependencyFile" skipped, due to false condition; ('$(GenerateDependencyFile)' == 'true' and '$(_UseBuildDependencyFile)' != 'true') was evaluated as ('true' == 'true' and 'true' != 'true').
2>Target "ComputeDependencyFileCompilerOptions" skipped, due to false condition; ('$(PreserveCompilationContext)' == 'true') was evaluated as ('' == 'true').
2>Building target "GenerateSingleFileBundle" completely.
2>Input file "C:\Workspaces\Framework\Main\Source\Core\Ice\obj\Release\net5.0-windows\win-x64\apphost.exe" is newer than output file "\\HYDRA\Data\SL\IceTool\Ice.exe".
2>Task "NETSdkError" skipped, due to false condition; ('$(IncludeAllContentForSelfExtract)' == 'true' And '$(IncludeNativeLibrariesForSelfExtract)' != 'true') was evaluated as ('false' == 'true' And 'false' != 'true').
2>Using "GenerateBundle" task from assembly "C:\Program Files\dotnet\sdk\5.0.101\Sdks\Microsoft.NET.Sdk\targets\..\tools\net472/Microsoft.NET.Build.Tasks.dll".
2>The "GenerateBundle" task failed unexpectedly.
2>System.IO.IOException: The process cannot access the file '\\HYDRA\Data\SL\IceTool\Ice.exe' because it is being used by another process.
2> at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
2> at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
2> at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
2> at System.IO.File.OpenWrite(String path)
2> at Microsoft.NET.HostModel.Bundle.Bundler.GenerateBundle(IReadOnlyList`1 fileSpecs)
2> at Microsoft.NET.Build.Tasks.GenerateBundle.ExecuteCore()
2> at Microsoft.NET.Build.Tasks.TaskBase.Execute()
2> at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
2> at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext()
2>Target "_SGenCheckForOutputs" skipped, due to false condition; ('$(_SGenGenerateSerializationAssembliesConfig)' == 'On' or ('#(WebReferenceUrl)'!='' and '$(_SGenGenerateSerializationAssembliesConfig)' == 'Auto')) was evaluated as ('Auto' == 'On' or (''!='' and 'Auto' == 'Auto')).
2>Comparison path is "C:\Workspaces\Framework\Main\Source\Core\Ice".
2>Comparison path is "bin\Release\net5.0-windows\win-x64\".
2>Comparison path is "obj\Release\net5.0-windows\win-x64\".
========== Build: 1 succeeded, 0 failed, 4 up-to-date, 0 skipped ==========
========== Publish: 0 succeeded, 1 failed, 0 skipped ==========
The deploy target folder (initially empty) contains just the single Ice.exe file. The same file that is "in use".
Here is my ClickOnceProfile.pub.xml file:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>
<GenerateManifests>True</GenerateManifests>
<Install>true</Install>
<InstallFrom>Unc</InstallFrom>
<InstallUrl>\\HYDRA\Data\SL\IceTool\</InstallUrl>
<IsRevisionIncremented>True</IsRevisionIncremented>
<IsWebBootstrapper>False</IsWebBootstrapper>
<ManifestCertificateThumbprint>(removed!)</ManifestCertificateThumbprint>
<MapFileExtensions>true</MapFileExtensions>
<OpenBrowserOnPublish>false</OpenBrowserOnPublish>
<Platform>Any CPU</Platform>
<ProductName>IceTool</ProductName>
<PublishDir>\\HYDRA\Data\SL\IceTool\</PublishDir>
<PublishUrl>\\HYDRA\Data\SL\IceTool\</PublishUrl>
<PublishProtocol>ClickOnce</PublishProtocol>
<PublishReadyToRun>True</PublishReadyToRun>
<PublishSingleFile>True</PublishSingleFile>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>False</SelfContained>
<SignatureAlgorithm>sha256RSA</SignatureAlgorithm>
<SignManifests>True</SignManifests>
<TargetCulture>en-GB</TargetCulture>
<TargetFramework>net5.0-windows</TargetFramework>
<UpdateEnabled>True</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
</PropertyGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.NetCore.DesktopRuntime.5.0.x64">
<Install>true</Install>
<ProductName>.NET Desktop Runtime 5.0.1 (x64)</ProductName>
</BootstrapperPackage>
</ItemGroup>
</Project>
Could this be a bug in a relatively new framework release? (Parallel task condition?) or any I doing something wrong. Thanks.
After adding a new index in datomic I got this Error.
The very same problem occured on one of my systems some Years ago and is still not fixed:
2018-11-27 10:23:37.580 WARN default datomic.update - {:message "Index creation failed", :db-id "xxx-8eb416be-ec26-4bff-b4ce-503bb734026b", :pid 29822, :tid 15}
java.io.IOException: Datei oder Verzeichnis nicht gefunden
at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:1.8.0_191]
at java.io.File.createTempFile(File.java:2024) ~[na:1.8.0_191]
at datomic.external_sort$temp_file_io$reify__5949.make_temp_file(external_sort.clj:22) ~[datomic-transactor-pro-0.9.5656.jar:na]
at datomic.external_sort$file_system_sorter$fn__6044.invoke(external_sort.clj:113) ~[datomic-transactor-pro-0.9.5656.jar:na]
at clojure.core$map$fn__5587.invoke(core.clj:2747) ~[clojure-1.9.0-RC1.jar:na]
at clojure.lang.LazySeq.sval(LazySeq.java:40) ~[clojure-1.9.0-RC1.jar:na]
at clojure.lang.LazySeq.seq(LazySeq.java:49) ~[clojure-1.9.0-RC1.jar:na]
at clojure.lang.RT.seq(RT.java:528) ~[clojure-1.9.0-RC1.jar:na]
2018-11-27 10:23:37.602 WARN default datomic.index - {:message "merge-db failed", :pid 29822, :tid 15}
java.io.IOException: Datei oder Verzeichnis nicht gefunden
at java.io.UnixFileSystem.createFileExclusively(Native Method) ~[na:1.8.0_191]
at java.io.File.createTempFile(File.java:2024) ~[na:1.8.0_191]
at datomic.external_sort$temp_file_io$reify__5949.make_temp_file(external_sort.clj:22) ~[datomic-transactor-pro-0.9.5656.jar:na]
at datomic.external_sort$file_system_sorter$fn__6044.invoke(external_sort.clj:113) ~[datomic-transactor-pro-0.9.5656.jar:na]
Seems like datomic not being able to write down some cache for the indexing process.
It crashes always shortly after restart trying to do the indexing job.
Last time this occurred on one of my systems I contacted support #marshall from datomic. With his help I dumped the datebase, grabbed the backup, reduced the amount of data, assigned a lot of ram ... and it worked. This time that's is not possible.
found the SOLUTION
the transactor indexer ignores the path settings in the config file ("datomic.version" "0.9.5656" and before tested) and tries to save on actual relative file path.
I made the datomic-pro folder accessible and voilà it creates a ..../data directory and indexing works
in detail:
in my debian setup i have set the database path to data-dir=/var/lib/datomic
all the db and tmp files are correctly stored in /var/lib/datomic
the datomic pro installation is in /usr/local/share/datomic/datomic-pro-0.9.5656/
My relative path starting the transactor (via start-stop-daemon) is also /usr/local/share/datomic/datomic-pro-0.9.5656/.
indexing works in my case after:
chown datomic:datomic /usr/local/share/datomic/datomic-pro-0.9.5656/
or better
mkdir /usr/local/share/datomic/datomic-pro-0.9.5656/data
chown datomic:datomic /usr/local/share/datomic/latest/data
you can watch datomic creating a /usr/local/share/datomic/latest/data/indexer folder
Hope that helps!
I have a problem with the rabbitmq.client version when using easynetq but I do not know what EXACTLY is causing it! My solution contains a project for a WindowsService (exe file) and several library projects, all built against .NET 4.6.2.
In my exe.conf (of the service executable) file I see the following entry:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="RabbitMQ.Client" publicKeyToken="89e7d7c5feba84ce" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
This causes a crash with the following exception:
2017-10-20 09:58:49,185; [9]; INFO ; MqService1Log; [AppHost.Configure]; - Registering RabbitMQ server using the EasyNetQ library....
2017-10-20 09:58:49,260; [9]; ERROR; MqService1Log; [Program.Main]; - System.IO.FileLoadException: Die Datei oder Assembly "RabbitMQ.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)
Dateiname: "RabbitMQ.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce" ---> System.IO.FileLoadException: Die Datei oder Assembly "RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce" oder eine Abhängigkeit davon wurde nicht gefunden. Die gefundene Manifestdefinition der Assembly stimmt nicht mit dem Assemblyverweis überein. (Ausnahme von HRESULT: 0x80131040)
Dateiname: "RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce"
=== Zustandsinformationen vor Bindung ===
LOG: DisplayName = RabbitMQ.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce
(Fully-specified)
LOG: Appbase = file:///D:/Projects/BizBusMQSamples/MqService1/MqService1/MqService1/bin/Debug/
LOG: Ursprünglicher PrivatePath = NULL
Aufruf von Assembly : EasyNetQ, Version=2.0.4.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Diese Bindung startet im default-Load-Kontext.
LOG: Die Anwendungskonfigurationsdatei wird verwendet: D:\Projects\BizBusMQSamples\MqService1\MqService1\MqService1\bin\Debug\MqService1.vshost.exe.Config
LOG: Die Hostkonfigurationsdatei wird verwendet:
LOG: Die Computerkonfigurationsdatei von C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config wird verwendet.
LOG: In der Anwendungskonfigurationsdatei wurde eine Umleitung gefunden. 4.0.0.0 wird nach 5.0.0.0 umgeleitet.
LOG: Verweis nach der Richtlinie: RabbitMQ.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=89e7d7c5feba84ce
LOG: Die gleiche Bindung ist bereits aufgetreten und hat den Fehler hr = 0x80131040 verursacht.
bei System.Signature.GetSignature(Void* pCorSig, Int32 cCorSig, RuntimeFieldHandleInternal fieldHandle, IRuntimeMethodInfo methodHandle, RuntimeType declaringType)
bei System.Reflection.RuntimeMethodInfo.FetchNonReturnParameters()
bei System.Reflection.RuntimeMethodInfo.GetParameters()
bei System.Diagnostics.StackTrace.ToString(TraceFormat traceFormat)
bei System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
bei System.Exception.GetStackTrace(Boolean needFileInfo)
bei System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
bei System.Exception.ToString(Boolean needFileLineInfo, Boolean needMessage)
bei System.Exception.ToString()
bei System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args)
bei System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args)
bei System.String.Format(String format, Object arg0, Object arg1)
bei MqService1.AppHost.Configure(Container container) in D:\Projects\BizBusMQSamples\MqService1\MqService1\MqService1\AppHost.cs:Zeile 51.
bei ServiceStack.ServiceStackHost.Init()
bei MqService1.Program.Main(String[] args) in D:\Projects\BizBusMQSamples\MqService1\MqService1\MqService1\Program.cs:Zeile 30.
Something seems to require RabbitMQ.Client 5 while something else wants Version 4. Since EasyNetQ seems not to support 5.0.1 (I get an unknown method error in the connection factory when connecting), I did NOT upgrade to 5.0.1 and stay with RabbitMQ.Client 4.1.3.
If I change bindingRedirect to oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" (change version from 5 to 4) in the .conf file everything works fine. The problem is, that every time I build the project this is changed back to 5 again!
Maybe I have to add the following information: The solution contains a library project that contains some management functions. This project includes EasyNetQ.Management.Client but according to the NuGet information it has NO dependencies. However when I remove this library project from my solution, the config file is not changed.....
Any idea what is going on here and how I can solve it? Any help is greatly appreciated.
EDIT
If I remove the library project from the solution, it still changes my config file to version 5. It must be caused by something else.
Update #ThommyB : I just released EasyNetQ 2.2.0, care to try?
I have not seen this behavior before, I suspect there's still references or packages to RMQ 5.
Would you mind updating to this version? https://www.nuget.org/packages/EasyNetQ/2.3.0-alpha0002
That will get you the RabbitMQ 5 client. Not many other things have changed so I don't consider it a big risk.
I am trying to run a linux image i created with buildroot with libvirt.
If i use qemu-system-arm directly, everything works as intended:
/usr/bin/qemu-system-arm \
-M versatilepb \
-kernel output/images/zImage \
-dtb output/images/versatile-pb.dtb \
-drive index=0,file=output/images/rootfs.ext2,if=scsi,format=raw \
-append "root=/dev/sda console=ttyAMA0,115200" \
-net nic,model=rtl8139 \
-net user \
-nographic
However, when i try to create the xml from my qemu cmdline, it fails:
$ virsh domxml-from-native qemu-argv qemu.args
error: XML error: No PCI buses available
I also tried to create a basic XML by hand:
<?xml version='1.0'?>
<domain type='qemu'>
<name>Linux ARM</name>
<uuid>ce1326f0-a9a0-11e3-a5e2-0800200c9a66</uuid>
<memory>131072</memory>
<currentMemory>131072</currentMemory>
<vcpu>1</vcpu>
<os>
<type machine='versatilepb'>hvm</type>
<kernel>zImage</kernel>
<cmdline>root=/dev/sda console=ttyAMA0,115200</cmdline>
<dtb>versatile-pb.dtb</dtb>
</os>
<devices>
<disk type='file' device='disk'>
<source file='rootfs.ext2'/>
<target dev="sda" bus="scsi"/>
</disk>
<interface type='network'>
<source network='default'/>
</interface>
</devices>
</domain>
which fails with the same error:
$ virsh create guest-test.xml
error: Failed to create domain from guest-test.xml
error: XML error: No PCI buses available
I already tried with the brand-new and latest libvirt-3.0.0, without any success
What do i need to change in my cmdline/xml?
virsh domxml-from-native issue
The reason why the domxml-from-native command does not work is because the underlying code in libvirt that does the parsing expects the suffix of qemu-system- to be a canonical architecture name, and arm is not. In your case it would seem you want arm to map to armv7l which is a cannonical architecture name. You can pull this of by creating a soft-link qemu-system-armv7l that points you your system's qemu-system-arm and then use the location of the softlink in your qemu.args
code references
https://github.com/libvirt/libvirt/blob/v4.0.0/src/qemu/qemu_parse_command.c#L1906
https://github.com/libvirt/libvirt/blob/v4.0.0/src/util/virarch.c#L135
xml issues
Your xml is giving you the same error for multiple unrelated reasons. In the type element under os you need to specify arch="armv7l" (or some other canonical arm arch name). Note also that the kernel and dtb references need to be absolute paths or prefixed with a .. Finally some of the devices you have require a PCI bus and will not work with the machine you are going for. Consider the following alternative.
<domain type='qemu'>
<name>Linux ARM</name>
<uuid>ce1326f0-a9a0-11e3-a5e2-0800200c9a66</uuid>
<memory>131072</memory>
<currentMemory>131072</currentMemory>
<vcpu>1</vcpu>
<os>
<type arch="armv7l" machine='versatilepb'>hvm</type>
<kernel>/path/to/zImage</kernel>
<cmdline>root=/dev/sda console=ttyAMA0,115200</cmdline>
<dtb>/path/to/versatile-pb.dtb</dtb>
</os>
<devices>
<disk type="file" device="disk">
<driver name="qemu" type="qcow2"></driver>
<source file="/path/to/root.qcow2"></source>
<target dev="sda" bus="sd"></target>
</disk>
<serial type="tcp">
<source mode="bind" host="localhost" service="4000"></source>
<protocol type="telnet"></protocol>
</serial>
</devices>
</domain>
I tried to import my ant script. And it successful. But when i compile it. I got this error:
run-selected-file-in-src:
java.io.FileNotFoundException: ..\sounds\voice.wav (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:106)
at com.sun.media.sound.WaveFileReader.getAudioInputStream(WaveFileReader.java:205)
at javax.sound.sampled.AudioSystem.getAudioInputStream(AudioSystem.java:1162)
at SimpleSoundPlayer.<init>(SimpleSoundPlayer.java:35)
at SimpleSoundPlayer.main(SimpleSoundPlayer.java:12)
Exception in thread "main" java.lang.NullPointerException
at java.io.ByteArrayInputStream.<init>(ByteArrayInputStream.java:89)
at SimpleSoundPlayer.main(SimpleSoundPlayer.java:16)
D:\Windows\My Document\Latihan\Java\allsrc\ch04src\nbproject\ide-file-targets.xml:7: Java returned: 1
BUILD FAILED (total time: 0 seconds)
This is my folder structure
root
+-build(all *.class store here)
+-images
+-nbproject(netbeans create it)
+-sounds(voice.wav where i want to load)
+-src(all *.java - When i compile. All *.class will store to "build" folder)
+-build.xml
My question is why the class file(SimpleSoundPlayer.class) didn't find "..\sounds\voice.wav". But when i tried it from command-line "java SimpleSoundPlayer" it fine.
Why this happen?
This happens because you use a relative path to load the file : ..\sounds\voice.wav. When you do this, your app is very fragile, because it must be launched from a specific directory to work correctly.
I suspect that NetBeans launches your app from the root folder instead of launching it from the src or build folder.
I would recommend to put the voice.wav in your sources, so that it's copied into the build directory, along with your class files. Then you may load the file using the classloader, thanks to a call to Class.getResourceAsStream().
I FIGURE IT OUT!!!
Special Thx to "JB Nizet". Because him i know why it didn't find the wav file. So i just search how to change the default location(this case in root) netbeans to compile(I want netbeans to compile from "build" folder).
The key is in nbproject/ide-file-target.xml
root
+-build(all *.class store here)
+-images
+-nbproject(netbeans create it)
+-sounds(voice.wav where i want to load)
+-src(all *.java - When i compile. All *.class will store to "build" folder)
+-build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project basedir="../build" name="chap04 - Sound Effects and Music-IDE">
<!-- TODO: edit the following target according to your needs -->
<!-- (more info: http://www.netbeans.org/kb/41/freeform-config.html#runsingle) -->
<target name="run-selected-file-in-src">
<fail unless="run.class">Must set property 'run.class'</fail>
<java classname="${run.class}" failonerror="true" fork="true">
<classpath>
<pathelement path="build"/>
<pathelement location="."/>
</classpath>
</java>
</target>
So i just change on <project basedir=".." to <project basediir="../build" where i want netbeans to compile. With this change netbeans will compile that file in "build" folder. AND... WOWWW... That file run correctly :D