Running ASPX project developed in VB.NET on Mono 5+ gives some errors.
System.Web.Compilation.CompilationException
error VBNC30248: CHANGEME
Description: Error compiling a resource required to service this request. Review your source file and modify it to fix this error.
Details: error VBNC30248: CHANGEME
Error origin: Compiler
Error source file: /tmp/www-data-temp-aspnet-0/b95b1af2/App_Web_MenuBH.ascx.fd7eef68.7vxof078_1.vb
Exception stack trace:
I tried some suggestions from https://github.com/mono/mono-basic/issues/52 but didn't work.
I edited the file /usr/bin/vbnc as follow and it started to WORK!
BEFORE Editing:
#!/bin/sh
exec /usr/bin/mono --debug $MONO_OPTIONS /usr/lib/mono/4.5/vbnc.exe "$@"
AFTER Editing:
#!/bin/bash
for x; do
if [[ $x = '/tmp'* ]]; then
sed -i '1{/#Externa/d}' $x
fi
done
exec /usr/bin/mono /usr/lib/mono/4.5/vbnc.exe "$@"
Tested on Ubuntu 20.04 with Mono 6.8.0.123
Fixing UTF-8 Encodings Problems
With the above fixing method, I realized that Turkish characters in .ascx and aspx files shown as question mark (?) on the site.
I think this happens because of the first line (and first bytes) of the file removed by sed, and thus the UTF-8 encoding information of the file is lost.
Solution 1:
Specifying /codepage parameter for vbnc.exe in the file /usr/bin/vbnc fixed the problem for me. For UTF-8, codepage id is 65001.
#!/bin/bash
find /tmp -iname "*.vb" | while read f; do
sed -i '1{/#Externa/d}' $f;
done
exec /usr/bin/mono --debug $MONO_OPTIONS /usr/lib/mono/4.5/vbnc.exe /codepage:65001 "$@"
Solution 2:
Another possible solution is should be commenting the first line, instead of removing it completely.
#!/bin/bash
find /tmp -iname "*.vb" | while read f; do
sed -i "1 s|#ExternalChecksum|'#ExternalChecksum|" "$f"
done
exec /usr/bin/mono --debug $MONO_OPTIONS /usr/lib/mono/4.5/vbnc.exe "$@"
To examine the effected files, I went to a location like: /tmp/systemd-private-3bd056c36fda4632a0cd170469bbc343-apache2.service-MpcOti/tmp/www-data-temp-aspnet-0/