Login Page - Create Account

Support Board


Date/Time: Mon, 27 May 2019 04:27:59 +0000



ACSIL - DLL cannot be opened for writing

Support Request:
[2018-11-20 10:08:29]
User19165 - Posts: 207
Hi Sierra,

New issue for me just starting today and no idea why. Last week I was working on this indicator without issue but today every time I am going to compile this while Sierra is running then Visual Studio gives me the error message:

"1>LINK : fatal error LNK1168: cannot open ..\..\..\Sierra_DEV\Data\Theoretical Average.dll for writing"

I'm using the latest version of Sierra 1842 but previously was using 1823 without issue until today. I can do a clean then full solution rebuild and same issue. If I close sierra down and then try to do a build, no problem. The indicator also has sc.FreeDLL = 1

What could I be missing here?
[2018-11-20 10:26:47]
User907968 - Posts: 60
Check the release note for V1837 -

https://www.sierrachart.com/index.php?page=doc/Whats_New.php#SCVer1837

sc.freedll not used, dll must be manually released to allow build in external program such as VS
[2018-11-20 10:34:33]
User19165 - Posts: 207
Thanks for the reply, but this started to happen in version 1823 as well. Like I said, no problem last week. I just looked up the logs you referenced and then looked at my version 1842, not really sure what it is suggesting I do? I am building this from with visual studio, not within sierra...
[2018-11-20 11:01:59]
User907968 - Posts: 60
If you are building DLL in \sierra\data directory with sierra running, then you cannot write to it as it will be in use (DLL is no longer unloaded due to sc.FreeDLL = 1 command)

1) Release DLL -
Analysis - Build Custom Studies DLL
Build - Release All DLLs and Deny Load

2) Build your study in VS or whatever

3) Reload DLL -
Analysis - Build Custom Studies DLL
Build - Allow Load DLLs
[2018-11-20 19:04:04]
Sierra Chart Engineering - Posts: 72171
You need to follow through the instructions here when using an external build tool:
https://www.sierrachart.com/index.php?page=doc/AdvancedCustomStudyInterfaceAndLanguage.php#ModifyingAdvancedCustomStudyCode
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
[2018-11-21 02:18:45]
Kiwi - Posts: 263
Admin,

Would it be possible to make Release All DLLs and Allow Load DLLs selectable as keyboard shortcuts please?

That would allow SC users to just press a keyboard combo before recompilation (so they could combine to run one command to do everything). I imagine some people would be shutting compilers, opening SC and jumping all over their screens currently - a keyboard shortcut would keep everything tidy.

Thanks
Date Time Of Last Edit: 2018-11-21 02:37:04
[2018-11-21 05:24:38]
User19165 - Posts: 207
Keyboard shortcuts for this would be very convenient.
[2018-11-21 07:58:37]
User864893 - Posts: 21
For VS Developers would it be possible to trigger the DLL release & load from an outside script/programm so that it could be included in pre and post compile scripts. Think that would be an ideal solution.
[2018-11-21 09:23:15]
Sierra Chart Engineering - Posts: 72171
We can add keyboard shortcuts but there are UDP Port commands for this that you can use:
https://www.sierrachart.com/index.php?page=doc/UDPAPI.html

Let us know how those work because they have not been tested.

This is available in version 1846 to be released in a few minutes.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
Date Time Of Last Edit: 2018-11-21 09:23:27
[2018-11-21 11:21:17]
User864893 - Posts: 21
Perfect! release and load works fine via UDP. Compiled a short exe based on your UDPAPI example which has been added to pre/post compile.

Just did a quick and dirty test with 1846 :-)

Thanks a lot
[2018-11-22 04:42:04]
Kiwi - Posts: 263
Would you be kind enough to add Release All & Allow Load All to the UDP interface please?

Between Linux & Wine the directory paths get confused enough that SC can't use them even in the menu driven mode. Same in the UDP mode (don't release & if I release all, can't load one).
[2018-11-22 05:59:51]
Sierra Chart Engineering - Posts: 72171
Between Linux & Wine the directory paths get confused enough that SC can't use them even in the menu driven mode.
Provide us more information so we can resolve. We are not aware of this.

Would you be kind enough to add Release All & Allow Load All to the UDP interface please?
Yes.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
[2018-11-22 21:54:00]
Kiwi - Posts: 263
Manual version. 1 chart with multiple studies from the same dll (KiwX.dll on my ramdisk, /home/john/zRamdisk/SierraData , all my data is stored in ram for green / noise / ssd life improvement).

Original: https://i.imgur.com/pfg25fZ.png

Analysis Build Build Release all & insert to reload chart: https://i.imgur.com/jcROAzv.png

Analysis Build Build Load all ... returns us to the original


So now one file. Note that the SC directory is SC64 as shown here (but the data is set to the ramdisk directory above):

https://i.imgur.com/KtA8VeG.png

Opening Choose DLL to release shows: https://i.imgur.com/eYGsOR4.png

Using Folder I navigate to the ramdisk: https://i.imgur.com/GD6qSsu.png

Select kiwX_64.dll then choose Open (window goes away)


FOUND THE PROBLEM .. Initially I discovered that closing on kiwX.dll would work so I thought that having the 32 bit dll in the directory was causing a problem. So I deleted it. So picture above but without kiwX.dll in the directory. Opened SC again ... choose release kiwX_64.dll ... didnt work!!! So tried changing name in open box to kiwX.dll (even though not present) and when I selected open it unloaded the link to _64.dll & the next insert resulted in a blank chart.

I suspect this is a SC64 only problem that you can easily fix. Or it might be better to add a note to the documentation to skip the _64 ... actually is it necessary to include the path given that we're forced to use the data directory? Then the command could just be:

sock.sendto(b"RELEASE_DLL--KiwX.dll", ("127.0.0.1", 22903))
Date Time Of Last Edit: 2018-11-22 23:09:11
[2018-11-22 22:30:31]
Kiwi - Posts: 263
Just confirming the same using the socket ... in python I needed to load/unload KiwX.dll not KiwX_64.dll. It might be worth including the python script commands as an example in the docs as well as C++; as usual Python tends to make it easy.

https://i.imgur.com/83IcdQA.png
Date Time Of Last Edit: 2018-11-22 22:41:10
[2018-11-23 00:12:41]
User654912 - Posts: 20
UDP works for me.

Basic powershell script for users who might not have python installed. Run with .\udpunload.ps1

udpunload.ps1
---
$client = new-object net.sockets.udpclient(0)

$peerIP = "127.0.0.1"
$peerPort = "22904"

$send = [text.encoding]::ascii.getbytes("RELEASE_DLL--C:\SierraChart\Data\x.dll")

[void] $client.send($send, $send.length, $peerIP, $peerPort)

$client.close()
Exit
[2018-11-27 00:12:50]
TedMar - Posts: 96
Why is not a CheckBox for permanet enable "Release All & Allow Load All" ?

Mybe User864893 or any one post here example howto add UDPAPI to pre/post compile in VS?
and UDPAPI.exe source code file Example too.
[2018-12-07 07:53:26]
User19165 - Posts: 207
Sierra,

In post #12, you responded to post #11 saying that there would be a release / load all command, did this get implemented yet? I note the UDP documentation page does not make mention of this.
[2018-12-07 09:39:27]
Sierra Chart Engineering - Posts: 72171
Why is not a CheckBox for permanet enable "Release All & Allow Load All" ?
We do not understand this. This is not making sense to us. This cannot be permanent.

In post #12, you responded to post #11 saying that there would be a release / load all command, did this get implemented yet?
Yes this has been released and it is in 1849 and the documentation is now updated.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
Date Time Of Last Edit: 2018-12-07 09:39:39
[2018-12-17 00:00:15]
Kiwi - Posts: 263
Confirming operation of Python version for release all and load all (comment out last line to choose release without immediately loading it again :), 0.1ms delay after object creation before sending command):

import socket
from time import sleep
#UDP to socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sleep(0.0001)
sock.sendto(b"RELEASE_ALL_DLLS", ("127.0.0.1", 22903))
sock.sendto(b"ALLOW_LOAD_ALL_DLLS", ("127.0.0.1", 22903))

Date Time Of Last Edit: 2018-12-17 06:49:04
[2019-01-05 13:37:45]
PeterSt - Posts: 36
All,

Assumed this is the last thread about the unloading "issue", here a small addition from a newbie to Sierra, meant for other newbees.

So our DLL gets uploaded to "something". There it is executed once we denote it so with "Add Custom Study". Now it runs.
This fact cause the inability to not being able to compile it with an external tool (like Visual Studio). All right.
In the posts above has been explained how to circumvent that situation. In general this comes down to :
A. Cause the "something" (say Sierra Kernel) to unload the DLL;
B. Compile your latest version of it;
C. Load it back.

My post (and hopefully improvement on it) is about C. I mean, I don't see the procedure for it, and without really knowing how to do it, you could lose ages of time because of too many steps required. However, first off a possible unseen issue :

(I'll take the PowerShell commands for the examples)

$send = [text.encoding]::ascii.getbytes("RELEASE_ALL_DLLS")
[void] $client.send($send, $send.length, $peerIP, $peerPort)

When this part is executed, the DLL/Study will not load back in full. Take the "Draw To Chart Example" to show this, where the colored square in the top left corner will not show any more, after the above has been done and the Study has been reloaded. However, the text "Draw To Chart Example" which shows towards the bottom, is shown all right.
I could find now other way than again restarting Sierra. And this can't be the idea of it.

The (somehow) proposed code like this :

$send = [text.encoding]::ascii.getbytes("RELEASE_ALL_DLLS"
[void] $client.send($send, $send.length, $peerIP, $peerPort)
$send = [text.encoding]::ascii.getbytes("ALLOW_LOAD_ALL_DLLS"))
[void] $client.send($send, $send.length, $peerIP, $peerPort)

doesn't help a bit for the freeing, because right away it is loaded back and you again can not compile (link, actually) it.

In full, this is the code which works :

$client = new-object net.sockets.udpclient(0)

$peerIP = "127.0.0.1"
$peerPort = "22904"

$send = [text.encoding]::ascii.getbytes("RELEASE_ALL_DLLS")
[void] $client.send($send, $send.length, $peerIP, $peerPort)

#The DLL is now freed. Recompile/Link your DLL. Below we will be waiting for a keystroke from you.

write-host "Press any key to continue..."
[void][System.Console]::ReadKey($true)

#Compile done ? then load back all the custom DLL's :

$send = [text.encoding]::ascii.getbytes("ALLOW_LOAD_ALL_DLLS")
[void] $client.send($send, $send.length, $peerIP, $peerPort)

$client.close()

To me it did not seem obvious, but when doing it like this, you won't need to touch anything in Sierra, because your Custom Study well automatically reload as long as it is in your list of Studies for the Chart(s but I tested with one only).

What I did lastly, was obtaining each half of the powershell code in the Pre-Build Event of the Project Properties in Visual Studio and in the Post-Build Event, respectively (I use VS2010). This line goes in the Pre-Build Event :

powershell -executionPolicy bypass -file "c:\ClearDLL.ps1"

(the ClearDLL.ps1 file put in the root of C:\ but it can be anywhere)

which contains this code :

$client = new-object net.sockets.udpclient(0)

$peerIP = "127.0.0.1"
$peerPort = "22904"

$send = [text.encoding]::ascii.getbytes("RELEASE_ALL_DLLS")
[void] $client.send($send, $send.length, $peerIP, $peerPort)

$client.close()

#Repeat the above in this same .ps1 for each Sierra host('sIP address) (untested)

And this line goes in the Post-Build event :

powershell -executionPolicy bypass -file "c:\LoadDLL.ps1"

which contains this code :

$client = new-object net.sockets.udpclient(0)

$peerIP = "127.0.0.1"
$peerPort = "22904"

$send = [text.encoding]::ascii.getbytes("ALLOW_LOAD_ALL_DLLS")
[void] $client.send($send, $send.length, $peerIP, $peerPort)

$client.close()

#Repeat the above in this same .ps1 for each Sierra host('sIP address) (untested)

Notice that the Pre-Build Event was used instead of the Pre-Link Event so the Sierra host has somewhat more time to free the DLL's. If this time appears to be insufficient, some sleep timer has to be build in the ClearDLL.Ps1 (at the end of it).

All we now need to do is recompile/link and instantly our current studies come alive (or stay away when Build errors occurred).
A note of caution : The instantly coming alive is indeed so. And in a live trading environment this could be dangerous, but alas.

If this wasn't known already, I hope this helps someone.
Peter
imageSierra04a.png / V - Attached On 2019-01-05 13:26:13 UTC - Size: 24.41 KB - 82 views
Attachment Deleted.
imageSierra04b.png / V - Attached On 2019-01-05 13:36:14 UTC - Size: 23.28 KB - 57 views
[2019-01-28 17:54:06]
Viacheslav Malafeev - Posts: 88
Hi. I kindly request that you add the keybord shortcuts for Release All DLLs and Allow Load DLLs. I'm unable to use UDPAPI. Many other newbie users would welcome this, I'm sure.

Thanks!
[2019-03-03 19:42:06]
Jezz - Posts: 29
Hi

I've tried UDPAPI via python for unlocking DLLs while compiling as described in https://www.sierrachart.com/index.php?page=doc/UDPAPI.html#StudyDLL_ReleaseDLL

neither RELEASE_DLL nor ALLOW_LOAD_DLL didn't work for me.

However RELEASE_ALL_DLLS and ALLOW_LOAD_ALL_DLLS commands did the job !!!

Thanks for including them
[2019-05-21 17:05:03]
binaryduke - Posts: 166
Is this approach still working? Since updating to v1915 I'm finding that using UDP to release all DLLs (and reload) has stopped working.
[2019-05-22 00:13:18]
Sierra Chart Engineering - Posts: 72171
There have been no changes with this functionality.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.

To post a message in this thread, you need to login with your Sierra Chart account:

Login


Login Page - Create Account