m1gin 1751

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/


m1gin 0

2018-05: Eski versiyon Mono kurulumu:

Mono 5.10 ile nedense derlenmiş VB projeleri sorun çıkardı. Ve şuna benzer hata mesajları verdi:

System.Web.Compilation.CompilationException

error VBNC30248: CHANGEME


O yüzden eski versiyon (4.6.2) kurulararak sorun çözüldü.

  • nano /etc/apt/sources.list.d/mono-official-stable.list

Dosya düzenlendi ve içeriği şu şekilde değiştirildi:

deb https://download.mono-project.com/repo/ubuntu wheezy/snapshots/4.6.2 main


Ancak bu defa da libapache2-mod-mono paketi kurulamadı ve daha eski versiyon apache istendi. Bunun üzerine bu paket sona bırakıldı ve en son dosya şu şekilde düzenlendi:

nano /etc/apt/sources.list.d/mono-official-stable.list

deb https://download.mono-project.com/repo/ubuntu stable-xenial main




Mono Tips

Create dll library with Mono:

For vb.net codes: vbnc, vbnc2
For c# classes: mcs

  • vbnc2 -target:library -imports:System.Text -r:bin/mbLib.dll -imports:System.Web -out:test.dll Ads.vb Custom.vb Common.vb DBTables.vb


WORKAROUNDS

In some cases, If mod-mono-server2 is called instead of mod-mono-server4, a symbolic link can be useful.

ln -s /usr/bin/mod-mono-server4 /usr/bin/mod-mono-server2



ERRORS

Error:

Could not load file or assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.

Solution:

yay -S mono-basic

Add to: